WA了前两个点

P1434 [SHOI2002] 滑雪

一只小狐狸 @ 2018-11-04 17:37:54

include <bits/stdc++.h>

using namespace std; int r,c; int hi[105][105],f[105][105]; const int a[4]={0,1,0,-1},b[4]={1,0,-1,0}; struct point { int x,y,h; }; point u[20001]; int cmp(point s,point t) { return s.h<t.h; } int ans=0; void read() { int i,j; cin>>r>>c; for (i=1;i<=r;i++) { for (j=1;j<=c;j++) { cin>>hi[i][j]; u[(i-1)r+j].x=i; u[(i-1)r+j].y=j; u[(i-1)r+j].h=hi[i][j]; } } sort(u+1,u+rc+1,cmp); //cout<<1<<endl; for (i=1;i<=rc;i++) { int xi=u[i].x,yi=u[i].y; f[xi][yi]=1; //cout<<i<<endl; for (j=0;j<=3;j++) { if (xi+a[j]>0 && xi+a[j]<=r && yi+b[j]>0 && yi+b[j]<=c) { if (hi[xi+a[j]][yi+b[j]]<hi[xi][yi]) { f[xi][yi]=max(f[xi][yi],f[xi+a[j]][yi+b[j]]+1); } } } } for (i=1;i<=r;i++) { for (j=1;j<=c;j++) { ans=max(ans,f[i][j]); } } cout<<ans<<endl; } int main() { read(); return 0; } /求助


by qseer @ 2018-11-04 17:53:21

希望更丰富的展现?使用Markdown


|