90分,WA第一点,求大佬找错

P1434 [SHOI2002] 滑雪

iMiku @ 2018-07-25 18:07:02

如题

#include<bits/stdc++.h>
using namespace std;
struct he
{
    int x,y,high;
}h[10010];
bool cmp(he a,he b)
{
    return a.high<b.high;
}
int maxheight[110][110],height[110][110];
int r,c,ud[5]={0,1,-1,0,0},lr[5]={0,0,0,-1,1};
int maxn;
int main()
{
    int t=1;
    cin>>r>>c;
    for(int i=1;i<=r;i++)
    {
        for(int j=1;j<=c;j++)
        {
            cin>>height[i][j];
            h[t].x=i;h[t].y=j;h[t++].high=height[i][j];
            maxheight[i][j]=1;
        }
    }
    sort(h+1,h+t,cmp);
    for(int i=1;i<t;i++)
    {
        for(int j=1;j<=4;j++)
        {
            bool s=height[h[i].x+ud[j]][h[i].y+lr[j]]>h[i].high;
            if(h[i].x+ud[j]>0&&h[i].x+ud[j]<=r&&h[i].y+lr[j]>0&&h[i].y+lr[j]<=c&&s)
            {
                maxheight[h[i].x+ud[j]][h[i].y+lr[j]]=maxheight[h[i].x][h[i].y]+1;
            }
        }
    }
    for(int i=1;i<=r;i++)
    {
        for(int j=1;j<=c;j++)
        {
            maxn=max(maxn,maxheight[i][j]);
        }
    }
    cout<<maxn;
}

|