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 |
数据量最大20没问题,贴上代码 这应该是一般人的模拟想法#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator