| ||||||||||
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 |
这个为什么会超时啊,大家帮我看看啊!short a[5001][3]; main(){ int n,j,i,flag; char c[5001]; scanf("%d%s",&n,c); for(j=0;j+1<n;j++) if(c[j]!=c[j+1]) a[j][1]=1; for(flag=i=2;i<n;i++,flag=(flag+1)%3) for(j=0;j+i<n;j++){ if(c[j]==c[j+i]) a[j][flag]=a[j+1][(flag+1)%3]; else a[j][flag]=1+((a[j][(flag+2)%3]<a[j+1][(flag+2)%3])?a[j][(flag+2)%3]:a[j+1][(flag+2)%3]); } printf("%d",a[0][(flag+2)%3]); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator