Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

帮忙看一下,我的代码是哪里做了,怎么总是wrong啊!!

Posted by 591164048 at 2009-09-25 17:38:58 on Problem 1088
#include <iostream>
using namespace std;

int r[10000];//行 
int l[10000];//列 
int a[10000];
int b[100][100];
int c[100][100];
int m,n;


void input()
{
 		 	cin>>m>>n;
 		 int num=0;
 		 int k=0;
 		 for(int i=0;i<m;i++)
 		 {
		 				 for(int j=0;j<n;j++)
		 				 {
						 				 cin>>k;
						 				 
						 				 r[num]=i;
						 				 l[num]=j;
						 				 a[num]=k;
						 				 b[i][j]=k;
						 				 c[i][j]=0;
										 num++;
						 }
		 }
}




void selectsort()
{
	int k;
	int t;
	for(int i=0;i<m*n-1;i++)
	{
		k=i;
		for(int j=i+1;j<m*n;j++)
		{
			if(a[k]>a[j]) k=j;
		}
		t=a[i];
		a[i]=a[k];
		a[k]=t;
		t=r[i];
		r[i]=r[k];
		r[k]=t;
		t=l[i];
		l[i]=l[k];
		l[k]=t;
	}
}


int  run()
{ 		 
     selectsort();
		 int max=0;
 		 for(int i=0;i<m*m;i++)
 		 {
		 			if(r[i]!=0&&b[r[i]][l[i]]>b[r[i]-1][l[i]])
			    {
					 		c[r[i]][l[i]]=c[r[i]-1][l[i]] > c[r[i]][l[i]]?c[r[i]-1][l[i]]:c[r[i]][l[i]];	 
				  }
				  
				  if(r[i]!=n-1&&b[r[i]][l[i]]>b[r[i]+1][l[i]])
			    {
					 		c[r[i]][l[i]]=c[r[i]+1][l[i]] > c[r[i]][l[i]]?c[r[i]+1][l[i]]:c[r[i]][l[i]];	 
				  }
				  
				  if(l[i]!=0&&b[r[i]][l[i]]>b[r[i]][l[i]-1])
			    {
					 		c[r[i]][l[i]]=c[r[i]][l[i]-1] > c[r[i]][l[i]]?c[r[i]][l[i]-1]:c[r[i]][l[i]];	 
				  }
				  
				  if(l[i]!=n-1&&b[r[i]][l[i]]>b[r[i]][l[i]+1])
			    {
					 		c[r[i]][l[i]]=c[r[i]][l[i]+1] > c[r[i]][l[i]]?c[r[i]][l[i]+1]:c[r[i]][l[i]];	 
				  }
				  
				  c[r[i]][l[i]]++;
				  
				  max=c[r[i]][l[i]]>max?c[r[i]][l[i]]:max;
      }
      
      return max;
}


void output()
{
 		 cout<<run()<<endl;
}

				 
int main()
{
 	
			  input();
 				output();
 		return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator