Problem V
Snjóteppa
Languages
en
is

One day Nesi was going to drive to Reykjavík University, but it had snowed quite a bit. Some cars have gotten stuck in both lanes of his street and he’s unsure if he can make it out of the street, even using both lanes and driving against traffic. Even worse is the fact that cars are coming and going, so he has no idea when he can leave.
His street can be modeled as a grid with two rows and
Nesi tells you the initial state of the street and each time a change occurs, like a car getting stuck or unstuck, he lets you know. In between he asks you whether he can make it out of the street at that point in time.
Input
The first line of the input contains two integers
-
U
: Update cell ; if a car was stuck there it has become unstuck, if there was no car there before then a car got stuck there ( , ). -
Q: Nesi wants to know if he can make it out of the street as is.
Output
Each time Nesi asks whether he can make it out of the street, print a single line containing Jebb if he can start somewhere in the leftmost column, drive his car to the right, left, up and down through the cells (not diagonally) and end up in the rightmost column without hitting another car. If he can’t print Neibb.
Scoring
Group |
Points |
Constraints |
1 |
25 |
|
2 |
5 |
|
3 |
30 |
All cells in the lower row will contain a stuck car
and they will never become unstuck ( |
4 |
40 |
No further constraints. |
Sample Input 1 | Sample Output 1 |
---|---|
5 5 ...o. ..... U 2 3 Q U 1 3 U 2 3 Q |
Neibb Jebb |
Sample Input 2 | Sample Output 2 |
---|---|
5 7 ooooo ..... Q U 1 1 U 1 2 Q U 1 2 U 1 1 Q |
Jebb Jebb Jebb |
Sample Input 3 | Sample Output 3 |
---|---|
3 4 ... ... U 1 1 U 1 2 U 1 3 Q |
Jebb |