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

难道是rp?什么数据都能通过就是WA!

Posted by lhzlucky at 2006-12-25 16:14:51 on Problem 2002
#include<stdio.h>
#include<math.h>
#include<iostream>
using namespace std;
struct node
{
	int x;
	int y;
};
node a[1001];
int cmp(const void* n1,const void* n2)
{
	if((*(node*)n1).x>(*(node*)n2).x||((*(node*)n1).x==(*(node*)n2).x&&(*(node*)n1).y>(*(node*)n2).y))return 1;
	if(((*(node*)n1).x==(*(node*)n2).x&&(*(node*)n1).y==(*(node*)n2).y))return 0;
	return -1;
}
int BinSearch(node&K,int n)
      { 
        int low=0,high=n-1,mid; 
        while(low<=high){ 
          mid=(low+high)/2;
          if(a[mid].x==K.x&&a[mid].y==K.y) return mid;
          if(a[mid].x>K.x||a[mid].x==K.x&&a[mid].y>K.y)
             high=mid-1; 
          else
             low=mid+1;
         }
        return -1;
       } 
void main()
{
	int n,i,j,k;
	node nod;
    scanf("%d",&n);
	while(n)
	{
		for(i=0;i<n;i++)
			scanf("%d%d",&a[i].x,&a[i].y);
		qsort(a,n,sizeof(a[0]),cmp);
        k=0;
        for(i=0;i<n;i++)
		  for(j=i+1;j<n;j++)
		  {
			  if((a[i].x+a[j].x)%2!=(a[i].y+a[j].y)%2)continue;
			  nod.x=(a[i].x+a[j].x-a[i].y+a[j].y)/2;
			  nod.y=(a[i].y+a[j].y+a[i].x-a[j].x)/2;
			  if(BinSearch(nod,n)==-1)continue;
			   nod.x=(a[i].x+a[j].x-a[j].y+a[i].y)/2;
			  nod.y=(a[i].y+a[j].y+a[j].x-a[i].x)/2;
			  if(BinSearch(nod,n)==-1)continue;
			  k++;
		  }  
	   cout<<k/2<<endl;
	   scanf("%d",&n);
	}
}

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