#P3395. 路障

路障

Output Format

For each test case, output Yes or No, answering whether B can reach (n,n)(n,n).

2

2
1 1
2 2

5
3 3
3 2
3 1
1 2
1 3
1 4
1 5
2 2
Yes
Yes

Hint

Sample explanation:

Here 0 means passable, x means blocked, and B means B's current position. From left to right represents time.

Case 1:
0 0    0 0    0 B  (already reached)
B 0    x B    x 0
Case 2:
0 0 0 0 0    0 0 0 0 0    0 0 0 0 0    0 0 0 0 0
0 0 0 0 0    0 0 0 0 0    0 0 0 0 0    0 0 0 0 0
0 0 0 0 0    0 0 x 0 0    0 0 x 0 0    0 0 x 0 0
0 0 0 0 0    0 0 0 0 0    0 0 x 0 0    0 0 x 0 0
B 0 0 0 0    0 B 0 0 0    0 0 B 0 0    0 0 x B 0 ......(B can reach the target)

Constraints:

  • To prevent score farming, all testdata are handcrafted.
  • For 20%20\% of the testdata, n3n \le 3.
  • For 60%60\% of the testdata, n500n \le 500.
  • For 100%100\% of the testdata, n1000n \le 1000.
  • For 100%100\% of the testdata, T10T \le 10.

Translated by ChatGPT 5