Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

燃冰水果留念

Posted by lhn1599085 at 2016-04-05 12:59:02 on Problem 3617
//样板 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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator