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 |
求教为什么不能过啊#include <cstdio> #include <string> #include <cstdlib> #include <cstring> #include <iostream> #include <algorithm> using namespace std; char cows[2300]={0}; int main(){ int n; cin >> n; for(int i = 0; i < n; ++i) { cin >> cows[i]; } int first = 0, last = n - 1; for(int i = 1; i <= n && first <= last; ++i) { if(cows[first] > cows[last]) cout << cows[last--]; else if(cows[first] < cows[last]) cout << cows[first++]; else { int kiss = 0; for(int j = 0; first+j <= last; ++j) { if(cows[first+j] < cows[last-j]) {kiss = 1; break;} else if(cows[j] > cows[last-j]) {kiss = 0; break;} } if(kiss) cout << cows[first++]; else cout << cows[last--]; } if(i % 80 == 0) cout << endl; } if(n % 80) cout << endl; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator