P2952 [USACO09OPEN] Cow Line S

Description

Farmer John's N cows (conveniently numbered 1..N) are forming a line. The line begins with no cows and then, as time progresses, one by one, the cows join the line on the left or right side. Every once in a while, some number of cows on the left or right side of the line all leave the line to go graze in their favorite pasture. FJ has trouble keeping track of all the cows in the line. Please help him. The cows enter the line in numerical order 1..N, and once a cow leaves the line she never re-enters it. Your program will be given S (1

Input Format

N/A

Output Format

N/A

Explanation/Hint

Input Resulting Cow Line A L 1 A L 2 1 A R 2 1 3 A L 4 2 1 3 D R 2 4 2 A R 4 2 5 A R 4 2 5 6 D L 1 2 5 6 A L 7 2 5 6 A R 7 2 5 6 8 感谢@ ws\_fuweidong 提供翻译。