O-Timberland
The main occupation of the Timberland city population is timberbay. Each year the habitant with the most correct answers is announced the winner. Besides the habitants, who are active during the day, in Timberland live growlins and cutlins, who are active during the night. Only then, they go out into the timbervalley and change its appearance. Growlins plant trees, sprinkle them with magic dust and the trees grow out by morning. Cutlins eat a whole tree without leaving stumps behind.
Early in the morning before sun comes out the habitants of Timberland pull out numbers Qi from a hat and with sunrise they have to pick up one of two bats, the ‘yes’ bat or the ‘no’ bat. The ‘yes’ bat should be picked up if a rectangular timberball court can be placed between the trees and the ‘no’ bat, if it is not possible. Every correct answer brings a point for the annual award. (Rectangular court is only a surface whose sides are parallel to the sides of the Timbervalley and whose sides must be integers.)
In the next Q lines are the events. The possible events are:
• grow x y Growlins planted a tree on the field (x,y)
• cut x y Cutlins ate a tree on the field (x,y)
• vote p Question “Is it possible that a rectangular court of the surface p can be placed in Timbervalley?”
(1 <= Q <= 50000), (1 <= [
] <= N^2), (1 <= x, y <= N), there will be no more than 365 events ‘vote p’ (For each day in the year there is one answer. Note that the announcement of the winner is at the end of the year).
[p]Warning: At the beginning there are no trees.
4 11
grow 1 4
vote 10
vote 12
grow 3 2
vote 7
vote 6
grow 4 3
grow 2 1
cut 3 2
vote 4
vote 9
Output:
no
yes
no
yes
yes
no
vote 10 - the answer is ‘no’ because it is not possible to place a rectangular court of the surface 10
vote 12 - the answer is ’yes’, one possibility is shown on the picture ‘Day 1’
vote 7 - the answer is ‘no’ because it is not possible to place a rectangular court of the surface 7
vote 6 - the answer is ‘yes’, one possibility is shown on picture ‘Day 2’
vote 4 - the answer is ‘yes’, one possibility is shown on picture ‘Day 3’
vote 9 - the answer is ‘no’ because it is not possible to place a rectangular court of the surface 9
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.