|Submit||All submissions||Best solutions||Back to list|
TR_GRID - Traversing Grid (challenge)
|Wersja polska||English version|
Starting at the top left corner of an NxM grid and facing towards the right, you keep walking one square at a time in the direction you are facing. If you reach the boundary of the grid or if the next square you are about to visit has already been visited, you turn right. You stop when all the squares in the grid have been visited. What direction will you be facing when you stop?
For example: Consider the case with N=3, M=3. The path followed will be (0,0) -> (0,1) -> (0,2) -> (1,2) -> (2,2) -> (2,1) -> (2,0) -> (1,0) -> (1,1). At this point, all squares have been visited, and you are facing right.
The first line contains T (T<10001) the number of test cases. Each of the next T lines contain two integers N and M (0<N,M<=109), denoting the number of rows and columns respectively.
Output T lines, one for each test case, containing the required direction you will be facing at the end. Output L for left, R for right, U for up, and D for down.
Author of this problem is Varun Jalan.
|Added by:||Piotr Ką kol|
|Cluster:||Cube (Intel G860)|
|Languages:||All except: NODEJS OBJC SCM qobi VB.NET|
|Resource:||Copy of Varun Jalan's task TRGRID with different scoring|
2013-12-03 13:00:37 Linghui Liu
First time to be shortest by only one submission:)
Last edit: 2013-12-03 13:01:10
2013-12-02 20:21:10 ওয়াসী (Wasi)
ha ha ha!
After submitting a 38B solution thought i finally managed the best score for AWK. But here is also same thing best is 37B in AWK(by both dominique and piotr)
I guess i should start from scratch again :P
2010-04-18 15:34:51 Piotr KÄ…kol
2010-04-17 16:11:23 Piotr KÄ…kol
I see I have always to copy file with tests and correct it by such a program:
// Edit: I'll look into it later (probably tomorrow). Sorry. Lack of time today.
Last edit: 2010-04-17 16:20:28
2010-04-17 15:55:25 numerix
Could you please check the data. I get AC at TRGRID, but RTE at TR_GRID.
Edit: Now my AC Lua-Version for TRGRID and TR_GRID has changed to WA after some minutes ...
Last edit: 2010-04-17 16:38:42