HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Kovrov IT > problem:


2008.A. 50672 - Math and Soldiers

Guest
• Discussion of problem (1)

Volume problems

• 2007.D. 50271 - Factorial
• 2007.E. 50663 - Lights
• 2007.F. 50690 - Parliament
• 2007.G. 50272 - Strange Numbers
• 2007.H. 50273 - Two Captains
• 2007.I. 50274 - Boundary Troops
• 2007.J. 50275 - Wedding
• 2007.K. 50276 - Nice Floor
• 2008.A. 50672 - Math and Soldiers
• 2008.B. 50261 - Roads
• 2008.C. 50262 - Brackets
• 2008.D. 50279 - Bit Decoder
• 2008.E. 50263 - Points
• 2008.F. 50972 - Division
• 2008.G. 50264 - String Multiplication
• 2008.H. 50254 - Lawyers Council
• 2009.A. 50283 - Tetris 3D

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Автор: Павел Кузнецов, ПГУ.

The regiment consisting of N mathematicians came to war camp. Commander arranged them in one line and then gave the order "On your left!". Each mathematician knows perfectly, that "left" is a very ambiguous definition, that's why each one turned 90° in arbitrary direction (clockwise or counterclockwise).
As for the punishment, the commander made each soldier to count the number of people this soldier can see and to shout out this number loud.
Soldier A can see soldier B if and only if the following statements are true:

1. A is looking in B direction.
2. There is no one in the line between A and B, or all soldiers between A and B have smaller height than B.

Your task is to write a program that will find out, how many soldiers each soldier does see.

Input
In the first line an integer number N is written - the number of soldiers in a line (1 ≤ N ≤ 105). In the second line the arrangement of soldiers is given, i.e. their directions (angle bracket shows the direction, watch sample for clarification). Angle brackets are separated by spaces. In next N lines numbers Hi are written - the height of i-th soldier (1 ≤ H ≤ 105). People in line are numbered from 1 to N from left to right.
Output
Output file should consist of N lines. In first line should be the number of people that first soldier sees, in second line - the second soldier etc.

Input 1 Output 1 Input 2 Output 2 Input 3 Output 3
2
< >
1
2
0
0
2
> >
1
2
1
0
5
> < < < >
4
2
3
100
1
3
1
2
2
0

Для отправки решений необходимо выполнить вход.

www.contester.ru