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

Re:why WA? 汗了...

Posted by snake19851124 at 2008-03-22 10:59:13 on Problem 3505
In Reply To:why WA? 汗了... Posted by:nash635 at 2008-03-21 23:59:50
> 哪位大牛帮看下啊!给的数据可以过!
> 实在是想不出来还有什么别的情况了!
> #include "iostream"
> #include "cmath"
> #define MAX_N 51
> using namespace std;
> struct ppos
> {
> 	int x,y;
> };
> int count,sum,h,l;
> int park[MAX_N][MAX_N];
> struct ppos pos[2501];
> int cpos[MAX_N]={0};
~~~~~~~~~~~~~~上面的cpos每次都得初始化,帮你放到下面去就过了
> 
> int tiny(int a,int b)
> {
> 	if(a<b)
> 		return a;
> 	else
> 		return b;
> }
> 
> int main()
> {
> 	int i,j,N;
> 	cin>>N;
> 	while(N--)
> 	{
> 		sum=0;
> 		count=0;
> 		cin>>h>>l;
> 		for(i=0;i<h;i++)
> 			for(j=0;j<l;j++)
> 			{
> 				cin>>park[i][j];
> 				if(park[i][j] != -1)
> 				{
> 					pos[park[i][j]-1].x=i;
> 					pos[park[i][j]-1].y=j;
> 					count++;
> 				}
> 			}
> //			for(i=0;i<count;i++)
> //				cout<<pos[i].x<<" "<<pos[i].y<<endl; 
> 			for(i=0;i<count;i++)
> 			{
> 				sum+=pos[i].x * 20 +tiny(abs(pos[i].y - cpos[pos[i].x]),l-abs(pos[i].y - cpos[pos[i].x])) * 5	;
> 				cpos[pos[i].x]=pos[i].y;
> 			}
> 			cout<<sum<<endl;	
> 	}
> 	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