Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
燃冰水果留念//样板 2016年4月5日 12:58:50 #include <iostream> #include <iomanip> #include <string> #include <algorithm> #include <vector> #include <queue> #include <cstdio> #include <cstring> #include <cmath> using namespace std; const int MAX_N = 2000; int N; char S[MAX_N + 1]; void solve(){ int a=0,b=N-1,k=0; while(a<=b){ bool left = false; k++; for(int i=0;i+a<=b;i++){ if(S[a+i] < S[b-i]){ left = true; break; } else if(S[a+i] > S[b-i]){ left = false; break; } } if(left) putwchar(S[a++]); else putwchar(S[b--]); if(k%80 == 0) puts(""); } puts(""); } int main() { while(cin >> N){ for(int i=0;i<N;i++) cin >> S[i]; solve(); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator