给定长度为N(1≤N≤2000)的字符串S,要构造一个长度为N的字符串T.期初,T是一个空串,随后反复进行下列任意操作. ·从S的头部删除一个字符,加到T的尾部 ·从S的尾部删除一个字符,加到T的尾部 目标是要构造字典序尽可能小的字符串 提示Input · Line 1: 一个整数(integer): N· Lines 2~N +1: Line i+1 contains a single initial ('A'..'Z') of the string in the ith position i…
POJ 3617 Best Cow Line Time Limit: 1000MS Memory Limit: 65536K [Description] [题目描述] FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual "Farmer of the Year" competition. In this contest every farmer arranges his cows in a line and herds…
本题使用贪心法.关键是考贪心策略.同一时候要求要细心,我提交的时候也WA了几次.大意题目就是怎样依照给定的规则排列一个01字符串,引用原题例如以下: C. Team time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Now it's time of Olympiads. Vanya and Egor decided to make his…
Best Cow Line Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 16104 Accepted: 4547 Description FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Year" competition. In this contest every farmer arrang…
3301: [USACO2011 Feb] Cow Line Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 67 Solved: 39[Submit][Status] Description The N (1 <= N <= 20) cows conveniently numbered 1...N are playing yet another one of their crazy games with Farmer John. The co…
直接用STL的的deque就好了... ---------------------------------------------------------------------- #include<cstdio> #include<algorithm> #include<cstring> #include<iostream> #include<deque> #define rep( i , n ) for( int i = 0 ; i &l…