零分代码求调!

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 m1kusama @ 2022-07-29 20:10:13

这是我们机房的大佬,今天遭受了重大打击,求好心人帮帮忙!调一下吧!!!!!!!!!!!!!!!!!!!!!!!!!!!


by Solgareo @ 2022-07-29 20:14:34

i{1} j{1} 为什么是大括号


by ReverBer @ 2022-07-29 20:15:22

主函数第一行int ans=0;


by myyyIisq2R @ 2022-07-29 20:16:26

脑瘫忘记初始化 ans0


by wukaichen888 @ 2022-07-29 20:23:16

刚才发错了\ if(nx>0&&ny>0&&nx<=n&&ny<=m&&mmap[nx][ny]<mmap[x][y])\ 不对呀,应该是 mmap[nx][ny]>mmap[x][y]


by wukaichen888 @ 2022-07-29 20:26:32

hack 数据:
5 5
1 2 3 4 5
10 9 8 7 6
11 12 13 14 15
20 19 18 17 16
21 22 23 24 25

by ReverBer @ 2022-07-29 20:33:32

@wukaichen888 hack输出是多少


by myyyIisq2R @ 2022-07-29 20:35:19

@wukaichen888 不是向低处滑嘛


by ReverBer @ 2022-07-29 20:44:09

@wangmingwei can can need&&sword new new


by wukaichen888 @ 2022-07-29 20:44:27

hack输出1

好像不是"<"的问题


| 下一页