Snake

You’ve decided to create the game Snake. To do that the first task you decide to tackle is to fill the whole field with a snake - that would be the maximum possible score in the game.
Given two integers h and w, your program should print the field filled with the path of the snake.
notion image
Input
Output
4 10
0 1 2 3 4 5 6 7 8 9 19 18 17 16 15 14 13 12 11 10 20 21 22 23 24 25 26 27 28 29 39 38 37 36 35 34 33 32 31 30
 

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue