2个RE,求助

P1434 [SHOI2002] 滑雪

abalabalabala @ 2024-05-16 16:25:39

#include <bits/stdc++.h>
using namespace std;
struct lu{
    int x,y;
    int g;
}qq[10005];
int r,c;
int f[10005];
bool cmp(lu a,lu b){
    return a.g>=b.g;
}
int check(lu a,lu b){
    int xx[4]={0,0,-1,1};
    int yy[4]={-1,1,0,0};
    int i;
    for(i=0;i<4;i++){
        if(a.x+xx[i]==b.x&&a.y+yy[i]==b.y)
            return 1;
    }
    return 0;
}
int main()
{
    int i,j,a,b=1;
    scanf("%d%d",&r,&c);
    for(i=0;i<r*c;i++){
        scanf("%d",&qq[i].g);
        qq[i].x=i/c;
        qq[i].y=i%c;
        f[i]=1;
    }
    sort(qq,qq+r*c,cmp);
    for(i=1;i<r*c;i++){
        a=0;
        for(j=0;j<i;j++){
            if(check(qq[i],qq[j])&&qq[i].g<qq[j].g){
                f[i]=max(f[i],f[j]+1);
            }
        }
        b=max(b,f[i]);
    }
    printf("%d\n",b);
    return 0;
}

|