WA on #1#2

P1434 [SHOI2002] 滑雪

xyztapeplayer @ 2024-04-20 14:54:37

#include <bits/stdc++.h>
using namespace std;
struct node{
    int x,y,h;
};
int n,m,dp[105][105],b[105][105];
node a[10005];
bool cmp(node x,node y){
    return x.h>y.h;
}
void print(){
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++) cout<<dp[i][j]<<" ";
        cout<<endl;
    }
    cout<<endl;
}
int main() {
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            int p;
            cin>>p;
            a[(i-1)*n+j]={i,j,p};
            b[i][j]=p;
        }
    }
    sort(a+1,a+1+n*m,cmp);
    for(int i=1;i<=n*m;i++){
        node k=a[i];
        if(k.h<b[k.x-1][k.y]) dp[k.x][k.y]=max(dp[k.x-1][k.y],dp[k.x][k.y]);
        if(k.h<b[k.x][k.y-1]) dp[k.x][k.y]=max(dp[k.x][k.y-1],dp[k.x][k.y]);
        if(k.h<b[k.x+1][k.y]) dp[k.x][k.y]=max(dp[k.x+1][k.y],dp[k.x][k.y]);
        if(k.h<b[k.x][k.y+1]) dp[k.x][k.y]=max(dp[k.x][k.y+1],dp[k.x][k.y]);
        dp[k.x][k.y]++;
        //cout<<k.x<<" "<<k.y<<" "<<k.h<<endl;
        //print();
    }
    int mx=-1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            mx=max(mx,dp[i][j]);
        }
    }
    cout<<mx;
    return 0;
}

by PluviaLaver @ 2024-04-20 15:18:59

a[(i-1)*n+j]={i,j,p};

改成

a[(i-1)*m+j]={i,j,p};

by PluviaLaver @ 2024-04-20 15:20:07

@Bed_War


by xyztapeplayer @ 2024-04-20 15:29:49

@PluviaLaver 谢谢,已关!


by xiao_dong_xi @ 2024-12-06 14:26:31

@xyztapeplayer

%%%


by xyztapeplayer @ 2024-12-06 15:06:40

@xiao_dong_xi 怎么你了


by xyztapeplayer @ 2024-12-06 15:09:46

@xiao_dong_xi 你行你别抄别人代码,你自己做


by xyztapeplayer @ 2024-12-06 15:21:35

@xiao_dong_xi 删了,否则我当开合处理


|