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 |
0秒AC模拟无压力!!!附代码#include<stdio.h> #include<string.h> #include<stdlib.h> int main() { int A[2312]; char str[2343]; int n,m,i,j,k,l,q,w,e,r; while(~scanf("%d",&n)) { while(n--) { scanf("%d",&m); A[0]=0; memset(str,0,sizeof(str)); for(i=1;i<=m;i++) { scanf("%d",&A[i]); } q=0; for(i=1;i<=m;i++) { for(j=0;j<A[i]-A[i-1];j++) { str[q++]='('; } str[q++]=')'; } k=strlen(str); for(q=0;q<k;q++) { if(str[q]==')') { int count=0; for(l=q-1;l>=0;l--) { if(str[l]!=')') count++; if(str[l]=='(') { str[l]='~'; break; } } printf("%d ",count); } } printf("\n"); } } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator