Lzr @ 2019-11-05 15:46:04
突然发现各样例好像luogu用户的初始头像……?
by Lzr @ 2019-11-05 15:50:49
顺便请dalao帮我康康错误北~ 64分 哇p2 p4 p6 p12
#include<bits/stdc++.h>
using namespace std;
int n,m,ans;
bool nmap[2510][2510];
int sum[2510][2510],dp[2510][2510],dp2[2510][2510];
int getsum(int a,int b,int x,int y){
return sum[x][y] - sum[x][b - 1] - sum[a - 1][y] + sum[a - 1][b - 1];
}
int main(){
cin >> n >> m;
for(int i = 1;i <= n;++i){
for(int j = 1;j <= m;++j){
scanf("%d",&nmap[i][j]);
sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + nmap[i][j];
dp[i][j] = nmap[i][j];
}
}
for(int i = 1;i <= n;++i){
for(int j = 1;j <= m;++j){
if(nmap[i][j]){
if(nmap[i - 1][j - 1])
if(getsum(i - dp[i - 1][j - 1],j - dp[i - 1][j - 1],i,j) == dp[i - 1][j - 1] + 1)
dp[i][j] = dp[i - 1][j - 1] + 1;
if(nmap[i - 1][j + 1])
if(getsum(i - dp2[i - 1][j + 1],j,i,j + dp2[i - 1][j + 1]) == dp2[i - 1][j + 1] + 1)
dp2[i][j] = dp2[i - 1][j + 1] + 1;
ans = max(max(dp[i][j],dp2[i][j]),ans);
}
}
}
cout << ans << endl;
}
私以为这么水的代码会t……
by 诱宵美⑨ @ 2019-11-05 15:51:53
红人问号
by Lzr @ 2019-11-05 15:53:51
@诱宵美九
这本来是美妙情头
by Lzr @ 2019-11-08 12:47:41
#include<bits/stdc++.h>
using namespace std;
//1736
int n,m,ans;
bool nmap[2510][2510];
int sum[2510][2510],dp[2510][2510],dp2[2510][2510];
int getsum(int a,int b,int x,int y){
return sum[x][y] - sum[x][b - 1] - sum[a - 1][y] + sum[a - 1][b - 1];
}
int main(){
cin >> n >> m;
for(int i = 1;i <= n;++i){
for(int j = 1;j <= m;++j){
scanf("%d",&nmap[i][j]);
sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + nmap[i][j];
dp[i][j] = nmap[i][j];
}
}
for(int i = 1;i <= n;++i){
for(int j = 1;j <= m;++j){
if(nmap[i][j]){
dp[i][j] = dp2[i][j] = 1;
if(nmap[i - 1][j - 1]){
int t1 = i - 1, t2 = j - 1;
while(dp[t1][t2] && getsum(i - dp[t1][t2],j - dp[t1][t2],i,j) != dp[t1][t2] + 1 && t1 >= 1 && t2 >= 1) --t1, --t2;
dp[i][j] = max(dp[t1][t2] + 1,dp[i][j]);
}
if(nmap[i - 1][j + 1]){
int t1 = i - 1, t2 = j + 1;
while(dp[t1][t2] && getsum(i - dp2[t1][t2],j,i,j + dp2[t1][t2]) != dp2[t1][t2] + 1 && t1 >= 1 && t2 <= m) --t1, ++t2;
dp2[i][j] = max(dp2[t1][t2] + 1,dp2[i][j]);
}
ans = max(max(dp[i][j],dp2[i][j]),ans);
}
}
}
cout << ans << endl;
/*for(int i = 1;i <= n;++i){
for(int j = 1;j <= m;++j) cout << dp[i][j] << " ";
cout << endl;
}
cout << endl;
for(int i = 1;i <= n;++i){
for(int j = 1;j <= m;++j) cout << dp2[i][j] << " ";
cout << endl;
}*/
}
改了下,92分,9tle了qwq
by Lzr @ 2019-11-08 12:52:59
a了!感谢大家!