| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 1024 MB | 30 | 25 | 20 | 80.000% |
A common pattern for country flags is three stripes. Some flags are really similar, and have exactly the same stripes in the same order, but the flag is rotated by 90ドル$ degrees. Using a sequence of colours, we can make a flag on a square grid, covering each row with the colours in the sequence. Another way to make a similar flag (that is rotated by 90ドル$ degrees), is by covering each column with the colours in the sequence.
In preparation for the Flags You Paint for Countries meeting, you notice a mistake for one of the flags: it should have been rotated counter-clockwise by 90ドル$ degrees! The square canvas is already stuck to a wall using super glue, so you can not simply take it off and rotate it. Therefore, you want to know how much work it would be to repaint one flag to the other. In one second, you can repaint one of the 1ドル \times 1$ squares to any colour. What is the minimum number of seconds you need to repaint the flag? As an example, for the flag in the first sample input (shown in Figure F.1), 34ドル$ squares need to be repainted.
Figure F.1: Two flags corresponding to the first sample input. Colour 1ドル$ corresponds to yellow, 2ドル$ to red, 3ドル$ to white, and 1000ドル$ to blue. When the first flag should be rotated counter-clockwise by 90ドル$ degrees without actually rotating the canvas, 34ドル$ squares need to be repainted.
The input consists of:
Output the number of cells that need to be repainted when the flag should be rotated counter-clockwise by 90ドル$ degrees.
7 1 2 2 3 1000 2 1
34
4 10 12 12 10
8
5 6 5 5 6 5
12
University > Delft University of Technology > Freshmen Programming Contest 2024 F번