#P7110. 晚秋绝诗
晚秋绝诗
Description
Watching the world-famous scenery of Country —Mount Cangwu—during late autumn is always a pleasant thing.
Mount Cangwu has peaks, numbered from to . At the beginning, the summits of all peaks are covered by autumn fog, so their heights cannot be distinguished.
At the same time, peak is called an intermediate peak if and only if its height is exactly the average of the heights of peak and peak (in particular, peak and peak are not intermediate peaks). In the Mount Cangwu area, flags are traditionally hung at the foot of some intermediate peaks. Initially, there are no flags at the foot of any peak.
There are days, and each day one of the following events happens:
- Fog clears / fog returns: the autumn fog at the summit of peak clears, or gathers again.
- Flag raised / flag lowered: the flag at the foot of peak is hung up, or taken down.
- Visitor: a mountaineering enthusiast visits Mount Cangwu to climb peak , and hopes to know its altitude on that day.
The enthusiasts learn heights in two ways: directly observing the altitude of peaks that are not covered by autumn fog, or using the “intermediate peak” information given by the flags at the feet of peaks on that day to deduce the heights of the remaining peaks as much as possible. Other methods are not allowed, including but not limited to communicating with previous visitors to share information.
Can you determine whether each enthusiast can know the height of the target peak?
Input Format
The first line contains two positive integers and , representing the number of peaks in Mount Cangwu and the number of days the events last.
The next lines each contain two positive integers , where . Specifically:
- For , it is guaranteed that . This means: if the summit of peak is foggy, it becomes fog-free; if it is fog-free, it becomes foggy.
- For , it is guaranteed that . This means: if there is no flag at the foot of peak , a flag is raised; if there is already a flag, it is lowered.
- For , it is guaranteed that . This means a mountaineering enthusiast who wants to climb peak visits.
Output Format
Output several lines. Each line contains one boolean value, in order, indicating whether each enthusiast can know the height: output if they can, and otherwise.
3 5
1 1
1 3
3 2
2 2
3 2
0
1
5 6
1 1
1 3
2 2
2 3
2 4
3 5
1
Hint
[Sample Explanation #1]
Without any intermediate-peak information, the first enthusiast cannot know the height of the peak covered by autumn fog.
When the second enthusiast visits, the heights of peak and peak are known, and peak is an intermediate peak, so the height of peak can be obtained by taking the average.
[Constraints]
This problem uses bundled testdata. You must pass all test points in a Subtask to get the score of that Subtask.
- Subtask #1 (7 points): , .
- Subtask #2 (13 points): .
- Subtask #3 (15 points): .
- Subtask #4 (20 points): .
- Subtask #5 (20 points): all events with occur after all events with .
- Subtask #6 (25 points): no special constraints.
For all testdata, it is guaranteed that , .
Translated by ChatGPT 5
京公网安备 11011102002149号