Zones
Time limit1sMemory limit128 MB
A diamond-shaped zone grows by extending one of four sides each step; output how many zones border each zone.
- Level
Medium7 of 10
- Topics
- Implementation, Geometry, Simulation
- Solved
- No attempts yet
Problem
To improve public transport in the capital, the transport company decided to change the boundaries of its fare zones. The old circular model is replaced by a rhombus model. The city is divided into zones numbered to .
Zone is a square with side length km, centered at the very center of the city. The square is rotated by 45 degrees, so its four vertices point north, east, south, and west. Zone is obtained by expanding the square of zone in one of the directions north, east, west, or south so that its side length becomes km. Each following zone is obtained by expanding the square again in one of these four directions, and each expansion makes the side km longer. When the square is expanded in a direction, the new square contains the previous one and shares with it the vertex opposite the chosen direction. Zone () is the region of the -th square that lies outside the -th square.
The figure below shows one possible division of the city into 4 zones: zone expands north, zone expands west, and zone expands north again.

The ticket price in each zone equals the number of zones that share a border with it. In the example above, the ticket price is 2 kuna in zone , 3 kuna in zone , 3 kuna in zone , and 2 kuna in zone .
Find the ticket price in every zone.
Input
The first line contains (), the number of zones.
Each of the next lines contains one of the letters S, I, Z, J. The letter on input line () is the expansion direction chosen for zone : S is north, I is east, Z is west, and J is south.
Output
Print lines. On the -th line, print the ticket price in zone .