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 |
模拟一下马上就出来了!0ms哦!#include <stdio.h> int main() { char s[100]; int count1,count2,i,j,n,k,cases,c; scanf("%d",&cases); while(cases--) { scanf("%d",&n); scanf("%d",&i); for(j=0;j<i;j++) s[j]='('; s[j++]=')'; n--; k=i; c=n; while(n--) { scanf("%d",&i); for(;k<i;k++) s[j++]='('; s[j++]=')'; k=i; } s[j]='\0'; //printf("%s\n",s); for(i=0;i<j;i++) { if(s[i]==')') { count1=1; count2=0; for(k=i-1;k>=0;k--) { if(s[k]=='(') count2++; if(s[k]==')') count1++; if(count1==count2) break; } if(c--) printf("%d ",count1); else printf("%d\n",count1); } } } return 1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator