零分代码求调!

P1434 [SHOI2002] 滑雪

myyyIisq2R @ 2022-07-29 20:07:12

ORZ

#include <bits/stdc++.h> // x y means x hang y lie
using namespace std;
int dx[4]{0,0,-1,1}; //up down left right
int dy[4]{-1,1,0,0}; //up down left right
int mmap[105][105]{};
int remember[105][105]{}; //remember data
int m{},n{}; //first input n!
int dfs(int x,int y)
{
    if(remember[x][y]) return remember[x][y];//return the memory
    //not be found yet
    remember[x][y] = 1;//init
    for(int i{};i<4;i++)// four directions
    {
        int nx = x+dx[i]; // next x
        int ny = y+dy[i]; // next y
        if(nx>0 && ny>0 && nx<=n && ny<=m/*check not go out*/ && mmap[nx][ny] < mmap[x][y]/*lower(must) than now place*/)
        {
            //ok
            //notice
            dfs(nx,ny);
            remember[x][y] = max(remember[x][y], remember[nx][ny]+1);
        }
    }
    return remember[x][y];
}
int main()
{
    int ans;
    cin>>n>>m;
    for(int i{1};i<=n;i++)
    {
        for(int j{1};j<=m;j++)
        {
            cin>>mmap[i][j];
        }
    }
    for(int i{1};i<=n;i++)
    {
        for(int j{1};j<=m;j++)
        {
            ans = max(ans,dfs(i,j));
        }
    }
    cout<<ans;
    return 0;
}

by ReverBer @ 2022-07-29 20:49:58

@wukaichen888 ?你拿什么程序跑出来1


by Solgareo @ 2022-07-29 20:51:52

@wukaichen888 跑出来是25啊 正解


by Decau @ 2022-08-06 09:58:42

你走反了


上一页 |