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 <cstring> #include <iostream> int main() { int n; scanf("%d",&n); while(n--) { int N; scanf("%d",&N); char *s=new char[2*N+1]; for(int i=0;i!=2*N;++i)s[i]=')'; s[2*N]=0; int pre; scanf("%d",&pre); int pos=pre; for(int i=0;i!=pre;++i)s[i]='('; for(int i=1;i!=N;++i) { int now; scanf("%d",&now); for(int j=0;j<now-pre;++j,++pos)s[pos+1]='('; ++pos; pre=now; } int count=1; for(int i=0;i<2*N;++i) { while(i<2*N && s[i]==')') { int cnt=1; int j=i-1; while(j>=0 && s[j]!='(') { if(s[j]=='5')++cnt; --j; } s[j]='5'; if(count>1)printf(" "); ++count; printf("%d",cnt); ++i; } } printf("\n"); delete[]s; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator