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

高手 为什么 一直 不能 accept 呢???????????????????????

Posted by 77q at 2010-07-30 15:29:58 on Problem 1065
#include<stdio.h>
#define MAX 20000
typedef struct
{
	int x;
	int y;
}point;
point a[6001],mina,minb;
int main()
{
	int t,i,j,k,m,n,z,d,step,g,w,q;
	scanf("%d",&t);
	for(j=0;j<t;j++)
	{
		scanf("%d",&n);
		for(k=0;k<n;k++)
			scanf("%d %d",&a[k].x,&a[k].y);
		step=0;
		m=0;
		while(m<n)
		{
			mina.x=MAX;
			mina.y=MAX;
			for(k=0;k<n;k++)
			{
			    if(mina.x>a[k].x&&a[k].x!=MAX)
				{   
					g=k;
				    mina.x=a[k].x;
				    mina.y=a[k].y;
				}
			    if(mina.x==a[k].x&&a[k].x!=MAX)
				{			
				    if(mina.y>a[k].y)
					{   
						g=k;
					    mina.x=a[k].x;
					    mina.y=a[k].y;
					}
				}
			}printf("%d %d %d",g,mina.x,mina.y);
			minb.x=a[g].x=MAX;
			minb.y=a[g].y=MAX;
			w=q=-1;
			m++;
			step++;
			z=0;
			while(z==0)
			{   d=0;
				for(i=0;i<n;i++)
				{
				    if(minb.x>=a[i].x&&minb.y>=a[i].y&&a[i].y>=mina.y&&a[i].x!=MAX&&w<=a[i].x&&q<=a[i].y)
					{
						if(minb.x==a[i].x)
						{
							if(minb.y>a[i].y)
							{   
								g=i;
					            minb.x=a[i].x;
					            minb.y=a[i].y;
							}
						}
						else
						{
							g=i;
							minb.x=a[i].x;
					        minb.y=a[i].y;
						}
					}
					else
					{
						if(minb.x==MAX)d++;
						if(d==n)z=1;
					}
				}
			    if(minb.x!=MAX)m++;
				w=a[g].x;
				q=a[g].y;
				minb.x=a[g].x=MAX;
			    minb.y=a[g].y=MAX;				
			}
		}
		printf("%d\n",step);
	}
	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