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 |
网上的这个DP拓扑序列 我对它提出严重质疑for (k = 2 ; k <= n; k ++ ) { for (x1 = 1 ; x1 <= 8 ; x1 ++ ) for (y1 = 1 ; y1 <= 8 ; y1 ++ ) for (x2 = x1; x2 <= 8 ; x2 ++ ) for (y2 = y1; y2 <= 8 ; y2 ++ ) { tmp = INF; // 竖切 for (a = x1; a < x2; a ++ ) { t = min(f[x1][y1][a][y2][k - 1 ] + s[a + 1 ][y1][x2][y2] * s[a + 1 ][y1][x2][y2] , f[a + 1 ][y1][x2][y2][k - 1 ] + s[x1][y1][a][y2] * s[x1][y1][a][y2]); if (tmp > t) tmp = t; } // 横切 for (b = y1; b < y2; b ++ ) { t = min(f[x1][y1][x2][b][k - 1 ] + s[x1][b + 1 ][x2][y2] * s[x1][b + 1 ][x2][y2] , f[x1][b + 1 ][x2][y2][k - 1 ] + s[x1][y1][x2][b] * s[x1][y1][x2][b]); if (tmp > t) tmp = t; } f[x1][y1][x2][y2][k] = tmp; } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator