Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
救命啊!!!我快疯了,怎么还不对阿?题号:1088#include<iostream.h> int main(){ int g[100][100]={0}; int b[10000][2]={0}; int l[100][100]={0}; int c[100][100]={0}; int dx[5]={0,0,1,0,-1}; int dy[5]={0,-1,0,1,0}; int Max=0; int i,j,k; int x,y; int n1,n2; do{ cin>>n1>>n2; }while(n1<1||n1>100||n2<1||n2>100); for(i=0;i<n1;i++) for(j=0;j<n2;j++) do{ cin>>g[i][j]; }while(g[i][j]<0||g[i][j]>10000); for(i=0;i<n1*n2;i++){ Max=0; for(j=0;j<n1;j++){ for(k=0;k<n2;k++){ if(c[j][k]==0&&g[j][k]>Max){ Max=g[j][k]; x=j; y=k; } } } b[i][0]=x; b[i][1]=y; c[x][y]=1; } for(i--;i>=0;i--){ j=1;Max=0;k=0; while(j<5){ x=b[i][0]+dx[j]; y=b[i][1]+dy[j]; if(x>=0&&x<n1&&y>=0&&y<n2){ if(g[x][y]>=g[b[i][0]][b[i][1]]){ j++; }else{ if(c[x][y]>Max){ Max=c[x][y]; k=j; } j++; } }else j++; } c[b[i][0]][b[i][1]]+=Max; l[b[i][0]][b[i][1]]=k; } Max=0; for(i=0;i<n1;i++){ for(j=0;j<n2;j++){ if(c[i][j]>Max){ Max=c[i][j]; x=i; y=j; } } } cout<<Max; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator