| ||||||||||
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:其实你开个c[2][5001]的够了。。In Reply To:用int超内存,用short就不超!!!!!!!!!!!!!!!!! Posted by:heliwen at 2009-03-22 16:51:31 部分代码如下: //c[5001][5001] for (int i = 0; i < 2; i++) c[0][i] = c[i][0] = 0; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (s[i] == s[N - j - 1]) c[i + 1][j + 1] = c[i][j] + 1; else if (c[i + 1][j] >= c[i][j + 1]) c[i + 1][j + 1] = c[i + 1][j]; else c[i + 1][j + 1] = c[i][j + 1]; } } //c[2][5001] for (int i = 0; i <= N; i++) c[0][i] = 0; c[1][0] = 0; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (s[i] == s[N - j - 1]) c[1][j + 1] = c[0][j] + 1; else if (c[1][j] >= c[0][j + 1]) c[1][j + 1] = c[1][j]; else c[1][j + 1] = c[0][j + 1]; } memcpy(c[0], c[1], (N + 1) * sizeof(int)); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator