Ryo_Yamada @ 2020-03-23 22:03:22
前缀和dp
我也知道这么短的代码肯定不对
16分WA,但重点是我硬是没hACk掉
#include <iostream>
#include <cstdio>
using namespace std;
int dp[2505][2505], leftpre[2505][2505], rightpre[2505][2505], ans;
bool fish[2505][2505];
int main() {
int n, m;
cin >> n >> m;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++) {
int x;
scanf("%d", &x);
fish[i][j] = x;
}
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
if(fish[i][j]) {
leftpre[i][j] = leftpre[i - 1][j - 1] + 1;
rightpre[i][j] = rightpre[i + 1][j + 1] + 1;
}
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
if(fish[i][j]) dp[i][j] = max(leftpre[i][j], rightpre[i][j]);
ans = max(dp[i][j], ans);
}
}
cout << ans;
return 0;
}
by WaReTle @ 2020-03-23 22:08:33
子矩阵别的地方不能有鱼
hack: 3 3 1 1 1 1 1 1 1 1 1
ans: 1
by Ryo_Yamada @ 2020-03-23 22:10:27
@qiliangzhe 哦↗↘
明白了,看来是我眼神不好
谢谢