| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 3 초 | 1024 MB | 66 | 17 | 15 | 31.250% |
Ondra has recently been promoted to Grand admiral of the Czech Navy. However, when he finally started thinking he had a secure job, the government announced budget cuts including dissolution of the Navy.
So Ondra decided to show the government how important the Czech Navy is. He knows from his spies about an upcoming naval battle of four great fleets. If he could win it, it would surely make enough of a demonstration.
Unfortunately, the Czech Navy has neither warships nor sea ports. But if Ondra's spies took over some ships he might have a chance. If only he knew which ships will survive the battle…
A naval battle goes as follows: Initially ship $i$ starts on square $(x_i, y_i)$, where both $x_i$ and $y_i$ are even. Additionally, the ship belongs to one of the four fleets: Northern, Southern, Eastern or Western. Then the battle proceeds in steps. In each step:
The battle ends when no crashes are possible anymore. A surviving ship is a ship that remains on the map after the end of the battle.
A ship moves according to the direction of its fleet. The movement in each direction changes its coordinates as follows:
The first line of inputs contains an integer $N$. Then $N$ lines follow, each containing $x_i$, $y_i$, and $d_i$, separated by spaces. The integers $x_i$ and $y_i$ are the coordinates of the $i$-th ship. The character $d_i$ is either N, S, E or W, describing the direction of the $i$-th ship's fleet.
No two ships initially have the same coordinates. That is, for ships $i$ and $j$ ($i \neq j$) either $x_i \neq x_j$ or $y_i \neq y_j$.
For each surviving ship, output a single line containing the integer $i$ ($1 \leq i \leq N$) — the number of the ship. You can output the numbers of surviving ships in any order.
If there are no surviving ships, the output should be empty.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 6 | $N = 2$ |
| 2 | 12 | $N \leq 100$, $x_i, y_i \leq 100$ (for each $i$ such that $1 \leq i \leq N$) |
| 3 | 8 | $N \leq 100$, $x_i, y_i \leq 10^5$ (for each $i$ such that $1 \leq i \leq N$) |
| 4 | 11 | $N \leq 200$ |
| 5 | 9 | $N \leq 5\,000$ |
| 6 | 30 | $d_i$ is either |
| 7 | 24 | no additional constraints |
7 0 6 E 0 8 E 2 4 E 4 2 S 6 0 S 6 2 S 6 4 S
7
The battle will initially look like this:
And then it proceeds as follows:
5 4 0 S 0 2 E 2 2 E 4 4 N 6 6 W
5 2
During the second step, ships 1, 3 and 4 will collide at $(2, 4)$. Ships 2 and 5 will survive.