HBC24876打毛玉大赛,数学,博弈论[USACO 2009 Ope S]Cow Line题解

你曾走过我的故事 算法基础篇 48 0
挑战自我,勇攀编程高峰!全网最全C++题库,助您成为编程达人。
Farmer John's N cows 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

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 <= S <= 100,000) input specifications; each appears on a single line and is one of two types: * A cow enters the line (a parameter indicates whether on the left or right). * K cows leave the line from the left or right side (supplied parameters define both the number of cows and which side). Input lines never request an operation that can not be performed. After all the input lines have been processed, your program should print the cows in the line in order from left to right. The final line is guaranteed to be non-empty at the end of the input specifications.

HBC24876打毛玉大赛,数学,博弈论[USACO 2009 Ope S]Cow Line题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
想要在职场中立于不败之地?那就来试试全网最全C++题库,让您在练习中快速提升技能。

标签: HBC24876打毛玉大赛 数学 博弈论[USACO 2009 Ope S]Cow Line题解