#P10665. [AMPPZ2013] Bytehattan
[AMPPZ2013] Bytehattan
Problem Description
Bytehattan has grid points, forming a grid graph. At the beginning, the whole graph is complete.
There are operations. In each operation, an edge in the graph is deleted. You need to answer whether and are still connected after deleting this edge.
Input Format
The first line contains two positive integers , representing the size of the grid graph and the number of operations.
The next lines describe the operations. Each line contains two pieces of information. Each piece of information contains two positive integers and a character ( is N or E).
If is N, it means deleting the edge from to . If is E, it means deleting the edge from to .
The data is encrypted. For each operation, if the previous answer was TAK or this is the first operation, only consider the first piece of information; otherwise, only consider the second piece of information. The data guarantees that each edge is deleted at most once.
Output Format
Output lines. For each query, if the two endpoints are still connected, output TAK; otherwise output NIE.
3 4
2 1 E 1 2 N
2 1 N 1 1 N
3 1 N 2 1 N
2 2 N 1 1 N
TAK
TAK
NIE
NIE
Hint
Constraints: , , .
Translated by ChatGPT 5