跪求磕头!!!大佬 哪里错了嬲!!!QAQ

P1434 [SHOI2002] 滑雪

Cuiyi_SAI @ 2021-07-25 10:53:30

#include <bits/stdc++.h>
using namespace std;
int R,C,a[101][101],num[101][101]={0},M=0;
bool check(int nx,int ny)
{
    return 1<=nx && nx<=R && 1<=ny && ny<=C;
}
int Maxnum(int sx,int sy)
{
    if(num[sx][sy]>0)
      return num[sx][sy];
    int ans=0;
    const int dx[5]={0,0,0,1,-1},dy[5]={0,1,-1,0,0};
    for(int i=1;i<=4;i++)
      {
        int nx=sx-dx[i],ny=sy-dy[i];
        if(!check(nx,ny)) continue;
        if(a[nx][ny]>=a[sx][sy]) continue;
        int t=Maxnum(nx,ny);
        if(ans<t)
          ans=t;
      }
    num[sx][sy]=ans+1;
    return ans+1;
}
int main()
{
    freopen("a.in","r",stdin);
    freopen("a.out","w",stdout);
    scanf("%d%d",&R,&C);
    for(int i=1;i<=R;i++)
      for(int j=1;j<=C;j++) scanf("%d",&a[i][j]);
    for(int i=1;i<=R;i++)
      for(int j=1;j<=C;j++)
        {
          Maxnum(i,j);
          if(M<num[i][j]) M=num[i][j];
        }
    printf("%d",M);
    fclose(stdin);
    fclose(stdout);
    return 0; 
} 

by ZBAA_MKC @ 2021-07-25 10:56:29

@璀翼 freopen没删


by Echidna @ 2021-07-25 11:25:18

草生


|