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 |
Re:自己测了很多数据都是正确的 但交上去却wa 请各路大侠帮忙看下啊In Reply To:自己测了很多数据都是正确的 但交上去却wa 请各路大侠帮忙看下啊 Posted by:huzuosheng at 2007-07-30 12:07:27 > #include <stdio.h> > #include <string.h> > > char seq[100]; > int pre[100]; > int max[100]; > > int main() > { > int i,j,k,l,b; > #ifndef ONLINE_JUDGE > freopen ("2955.txt","r",stdin); > #endif > > while(scanf("%s",seq)!=EOF&&seq[0]!='e') > { > memset(pre,-1,sizeof(pre)); > memset(max,0,sizeof(max)); > l=strlen(seq); > for(i=0;i<l;i++) > { > if(seq[i]=='('||seq[i]=='[') > { > max[i]=1; > pre[i]=i; > for(j=i-1;j>=0;j--) > { > if(seq[j]==')'||seq[j]==']') > { > max[i]=max[j]+1; > pre[i]=pre[j]; > break; > } > } > } > else > { > for(j=i-1;j>=0;j--) > { > b=0; > if(seq[j]==seq[i]-1||seq[j]==seq[i]-2) > { > if(max[i]<2) > { > max[i]=max[j]+1; > pre[i]=j; > } > for(k=i-1;k>j;k--) > { > if(pre[k]>j&&(seq[k]==')'||seq[k]==']')) > { > b+=max[k]-max[pre[k]]+1; > k=pre[k]; > } > } > if(b+max[j]+1>max[i]) > { > max[i]=b+max[j]+1; > pre[i]=j; > } > } > } > } > } > b=0; > for(i=0;i<l;i++) > if(seq[i]==')'||seq[i]==']') > if(b<max[i]) b=max[i]; > printf("%d\n",b); > } > return 0; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator