Traversal
Opened this issue · 0 comments
morris821028 commented
Problem Description
The task is to start from a given cell, traverse every cell of an
Subtasks
- 5pt.
$m = 2$ and$n = 2$ . - 10pt.
$m = 2$ and$n \geq 2$ . - 10pt.
$m = 4$ and$n \geq 2$ . - 20pt.
$m = 6$ and$n \geq 2$ . - 55pt.
$m$ is no more than 500, and$2 \leq n \leq 512$ .
Hints
- For any matrix of even number of columns, we can start from
$(0, 0)$ , go up to$(0, m - 1)$ , then go right to$(n - 1, m - 1)$ , then do a snake-like zig-zag traversal back to$(1, 0)$ , then go back to$(0, 0)$ .
There are many cases in one input file, please read it until EOF.
There are four numbers in one case.
The first two numbers means the size of the
The last two numbers means the cell that you start from.
Sample Input 1
2 2 0 0
Sample Output 1
0 0
0 1
1 1
1 0
0 0
Sample Input 2
3 4 1 2
Sample Output 2
1 2
2 2
2 3
1 3
0 3
0 2
0 1
0 0
1 0
2 0
2 1
1 1
1 2
Sample Input 3
2 2 0 0
3 4 1 2
Sample Output 3
0 0
0 1
1 1
1 0
0 0
1 2
2 2
2 3
1 3
0 3
0 2
0 1
0 0
1 0
2 0
2 1
1 1
1 2