关于这题

P1736 创意吃鱼法

SunXiaoping @ 2021-06-15 11:46:32

AC代码:

#include<bits/stdc++.h>
using namespace std;
int n,m,l,len[2510],a[2510][2510],dp[2510][2510],maxn;
int main()
{
    freopen("meal.in","r",stdin);
    freopen("meal.out","w",stdout);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        l=0;
        for(int j=1;j<=m;j++)
        {
            cin>>a[i][j];
            if(a[i][j])
            {
                dp[i][j]=min(dp[i-1][j-1],min(l,len[j]))+1;
                l=len[j]=0;
                maxn=max(maxn,dp[i][j]);
            }
            else
            {
                l++;
                len[j]++;
                //cout<<l<<" "<<len[j]<<"\n"; 
            }
        }
    }
    memset(len,0,sizeof(len));
    for(int i=1;i<=n;i++)
    {
        l=0;
        for(int j=m;j>=1;j--)
        {
            if(a[i][j])
            {
                dp[i][j]=min(dp[i-1][j+1],min(l,len[j]))+1;
                l=len[j]=0;
                maxn=max(maxn,dp[i][j]);
            }
            else
            {
                l++;
                len[j]++;
            }
        }
    }
    cout<<maxn<<"\n";
}

l和len数组是干嘛用的


by EC75 @ 2021-12-24 18:32:07

@explpl2007 全部WA。您真厉害


by Coros_Trusds @ 2022-05-23 19:44:17

@continue_and_break 建议仔细看看 freopen


|