#P7110. 晚秋绝诗

    ID: 5901 远端评测题 2500ms 250MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>平衡树洛谷原创O2优化洛谷月赛

晚秋绝诗

Description

Watching the world-famous scenery of Country LL—Mount Cangwu—during late autumn is always a pleasant thing.

Mount Cangwu has nn peaks, numbered from 11 to nn. At the beginning, the summits of all nn peaks are covered by autumn fog, so their heights cannot be distinguished.

At the same time, peak ii is called an intermediate peak if and only if its height is exactly the average of the heights of peak i1i-1 and peak i+1i+1 (in particular, peak 11 and peak nn 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 mm days, and each day one of the following events happens:

  • Fog clears / fog returns: the autumn fog at the summit of peak xx clears, or gathers again.
  • Flag raised / flag lowered: the flag at the foot of peak xx is hung up, or taken down.
  • Visitor: a mountaineering enthusiast visits Mount Cangwu to climb peak xx, 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 nn and mm, representing the number of peaks in Mount Cangwu and the number of days the events last.

The next mm lines each contain two positive integers op,xop, x, where op{1,2,3}op \in \{1,2,3\}. Specifically:

  • For op=1op = 1, it is guaranteed that 1xn1 \le x \le n. This means: if the summit of peak xx is foggy, it becomes fog-free; if it is fog-free, it becomes foggy.
  • For op=2op = 2, it is guaranteed that 2x<n2 \le x < n. This means: if there is no flag at the foot of peak xx, a flag is raised; if there is already a flag, it is lowered.
  • For op=3op = 3, it is guaranteed that 1xn1 \le x \le n. This means a mountaineering enthusiast who wants to climb peak xx visits.

Output Format

Output several lines. Each line contains one boolean value, in order, indicating whether each enthusiast can know the height: output 11 if they can, and 00 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 11 and peak 33 are known, and peak 22 is an intermediate peak, so the height of peak 22 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): n5n \le 5, m10m \le 10.
  • Subtask #2 (13 points): n,m100n, m \le 100.
  • Subtask #3 (15 points): n,m2000n, m \le 2000.
  • Subtask #4 (20 points): n,m105n, m \le 10^5.
  • Subtask #5 (20 points): all events with op=1op = 1 occur after all events with op=2op = 2.
  • Subtask #6 (25 points): no special constraints.

For all testdata, it is guaranteed that 3n51053 \le n \le 5 \cdot 10^5, 1m51051 \le m \le 5 \cdot 10^5.

Translated by ChatGPT 5