为什么一个点也过不了??

P1005 [NOIP2007 提高组] 矩阵取数游戏

高精警告
by aSunnyDay @ 2021-11-16 20:29:56


这题要高精....
by Yukinoshita_Yukino @ 2021-11-16 20:30:35


就算60也得开个 long long ...awa
by Skaditxdy @ 2021-11-16 20:46:19


@[Eroi](/user/131890) 建议您使用Python大法: ```python matrix=[] n,m=input().split() n,m=int(n),int(m) for i in range(n): row=input().split() row=[0]+[int(count)for count in row]+[0] matrix.append(row) a=[1] for i in range(m): a.append(a[i]*2) ans=0 for i in range(n): row=matrix[i] w=1 dp=[[0]*(m+2)]*(m+2) for st in range(1,m+1): for ed in range(m,0,-1): if ed<st: continue dp[st][ed]=max(dp[st-1][ed]+row[st-1]*a[m-ed+st-1],dp[st][ed+1]+row[ed+1]*a[m-ed+st-1]) ans+=max([dp[i][i]+row[i]*a[m]for i in range(1,m+1)]) print(ans) ``` Python**自带高精**
by EC75 @ 2021-12-26 19:57:32


|