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

数据量最大20没问题,贴上代码 这应该是一般人的模拟想法

Posted by hanzeil at 2014-08-17 20:56:24 on Problem 1068
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int N;
	cin>>N;
	while(N--){
		int psequence[22]={0};
		char s[100];
		int plen,slen=0;
		cin>>plen;
		for(int i=0;i<plen;i++)
			cin>>psequence[i];
		int leftnum=0;
		for(int i=0;i<plen;i++,slen++){
			for(int j=leftnum;j<psequence[i];j++,leftnum++)
				s[slen++]=0;
			s[slen]=1;
			int rnum=0,lnum=0;
			for(int j=slen;j>=0;j--){
				if(s[j]==1) lnum++;
				else rnum++;
				if(lnum==rnum) break;
			}
			cout<<rnum<<" ";
		}
		cout<<endl;
	}
}

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