| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 3 초 | 1024 MB | 16 | 5 | 5 | 62.500% |
It's the evening before the first day of CEOI 2024 and Křemílek and Vochomůrka are in their room, nervous about what's to come. To pass the time, they decided to play a game of Go. Sadly, neither of them brought a Go board. Luckily Křemílek always carries a matchbox in his pocket and Vochomůrka has an infinite grid in his backpack, which means they can play Go 2!
As the name implies, Go 2 differs from Go in two major ways: The board, and the rules.
Go 2 is played on a square grid. Players take turns placing matches on the grid. A match may be placed on any edge between two squares. If placing a match creates an enclosed area, the player that placed it receives a number of points equal to the area of the enclosed space, and the match is removed. Otherwise, the player receives no points and the match remains on the grid. It is prohibited to place a match in the position where a match was placed previously, even if that match has been removed.
Since computing areas of complex shapes can be difficult, Křemílek and Vochomůrka would like your help with evaluating their game. You will receive the list of all matches placed during their game (ordered as they were played). For each match, you should compute the number of points it was worth.
The first line of input contains the integer $N$ — the number of matches placed. $N$ lines follow, one per match. Each of them contains two numbers, $x_i$ and $y_i,ドル and a character $c_i,ドル separated by spaces. Each corner is identified by an $x$ and $y$ coordinate. If $c$ is x, then the match is placed on the edge between $(x, y)$ and $(x + 1, y)$. If $c$ is y, then the match is placed on the edge between $(x, y)$ and $(x, y + 1)$.
Your program should output $N$ lines, one for each match. It should contain a single number $s_i$ — the number of points the match was worth.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 25 | $N \leq 30,000円,ドル $x_i, y_i \leq 10,000円$ (for each $i$ such that 1ドル \leq i \leq N$) |
| 2 | 25 | $x_i, y_i \leq 10,000円$ (for each $i$ such that 1ドル \leq i \leq N$) |
| 3 | 25 | $N \leq 30,000円$ |
| 4 | 25 | no additional constraints |
4 0 0 x 0 0 y 1 0 y 0 1 x
0 0 0 1