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 |
3个滚动数组才行In Reply To:如此的滚动,为什么都是WC Posted by:smzzw at 2013-01-22 15:28:19 unsigned short dp[3][N]; char buf[N]; int main() { int n,s,e,x,y,z; scanf("%d",&n); getchar(); gets(buf); for(int i=1;i<n;i++){ for(int j=0;j+i<n;j++){ s=j,e=j+i; x=i%3,y=(i+2)%3,z=(i+1)%3; if(buf[s]==buf[e]) dp[x][s]=dp[z][s+1]; else dp[x][s]=min(dp[y][s+1]+1,dp[y][s]+1); } } printf("%d\n",dp[x][0]); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator