## Path Finder

View as PDF

Points: 10 (partial)
Time limit: 1.0s
Java 8 2.0s
PyPy 2 2.0s
PyPy 3 2.0s
Memory limit: 512M

Author:
Problem type

You are given an grid with blocked squares and the others open. From an open square, you may move to any other open square that shares an edge with your current square. Please find out whether there is a path from to .

#### Constraints

Each given blocked square is unique, and the squares and will not be blocked.

#### Input Specification

The first line will contain integers , , and .

The next lines will each contain integers and , representing that square is blocked.

#### Output Specification

Output one line containing YES if it is possible to reach from , or NO otherwise.

#### Sample Input 1

5 5 11
2 2
4 2
3 2
2 3
5 2
3 1
1 5
3 5
2 5
4 5
4 4

#### Sample Output 1

YES

#### Explanation for Sample 1

The following is a diagram for the grid given in Sample 1 (. marks open squares, while # marks blocked squares):

....#
.##.#
##..#
.#.##
.#...

It can be shown that there is a path from to in the grid above.

#### Sample Input 2

5 5 9
5 1
1 2
1 5
3 2
2 3
5 3
3 3
3 5
4 4

#### Sample Output 2

NO

#### Explanation for Sample 2

The following is a diagram for the grid given in Sample 2 (. marks open squares, while # marks blocked squares):

.#..#
..#..
.##.#
...#.
#.#..

It can be shown that there are no paths from to in the grid above.

• commented on May 3, 2022, 2:02 p.m.

"Let's have fun, friend!"

• commented on May 5, 2022, 9:24 a.m. edited

Ratio + Apex sucks!!

• commented on May 5, 2022, 2:03 p.m.

I bet you're a fortnite player

• commented on May 5, 2022, 9:24 a.m.

"Oh no, someone's shooting at us we're failing this problem!"

• commented on May 2, 2022, 11:10 p.m. edited

After swapping from Scanner to BufferedReader, my submission gets the java.util.NoSuchElementException. I am may be incorrectly using the BufferedReader (I am using the code provided at https://dmoj.ca/tips/), or if I have a mistake somewhere else in the program. I have read about this error on Oracle, but am still unable to figure out why it is happening, and cannot replicate the error in my program on IntelliJ. Any suggestion as to which sources I should read / or any test cases to try would help. Thank you! Edit: I fixed all the bugs and holy moly there were a LOT.

• commented on May 3, 2022, 9:08 a.m.

I believe you need to make a new String Tokenizer for each line of input, if you haven't done that already.