PivotOJ

Adolescent Architecture 2

시간 제한: 2000ms메모리 제한: 1024MB출처: GCPC 2023BOJ 28369

문제

Three years ago, you helped little Peter stack his toy blocks into a tower. Since then, he has extended his collection of toy blocks, which now features the following base shapes:

  • circle aa -- a circle of radius aa;
  • square aa -- a square with side length aa;
  • triangle aa -- an equilateral triangle with side length aa.

Here, aa may be any positive integer. The top shapes of each block are the same as their bottom shapes, so the blocks are cuboids, cylinders, and triangular prisms, respectively. Peter has an infinite supply of blocks of each shape and size.

Figure A.1: A game in progress.

Peter and his friend Amy are playing a two-player game, where the blocks need to be stacked on top of each other. Initially, some blocks are already placed on the floor. In each move, the current player must take a toy block from the infinite supply and put it on top of one of the existing stacks of blocks. The block may be rotated around its vertical axis before placing it. The outline of the new block must be strictly within the outline of the old block; the outlines are not allowed to touch. The first player who is unable to make a move loses the game.

Given the initial configuration, determine the number of winning moves for the first player.

입력

The input consists of:

  • One line with an integer nn (1n10001 \le n \le 1000), the number of initial stacks.
  • nn lines, each with a string ss (ss is one of "circle", "square" or "triangle") and an integer aa (1a1091 \le a \le 10^9), giving the topmost blocks of the initial stacks as described above.

출력

Output the number of winning moves for the first player.

힌트

Figure A.2: Illustration of Sample Input 2, showing all possible end configurations of the game when Peter went first and played optimally to win. The blue blocks are the initial configuration. Peter needs to put one of circle 1, square 2 or triangle 3 on top of circle 2 in order to win. Each of these options corresponds to one row of the figure. Blocks placed by Peter are coloured in red, and blocks placed by Amy are coloured in yellow. As the last two blocks are always of type triangle 1, they are shown in grey. If, for instance, Peter first puts circle 1 (as depicted in the first row), then Peter can win by mirroring the following moves by Amy.

예제

예제 1

입력
2
circle 2
triangle 2
출력
2

예제 2

입력
2
circle 1
circle 2
출력
3

예제 3

입력
5
circle 123
triangle 456
square 789
square 789
triangle 555
출력
7

예제 4

입력
3
circle 299303201
square 79724391
triangle 437068198
출력
3

예제 5

입력
3
square 539715887
circle 518408351
triangle 348712924
출력
0
코드를 제출하려면 로그인하세요.