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

一个小bug找了半天 贴一下源代码!汗

Posted by yangming13 at 2009-04-23 21:27:04 on Problem 2536
#include<iostream>
#include<stdlib.h>
#include<string>
#include<cmath>
using namespace std;
#define LEFT_MAX 110
#define RIGHT_MAX 110
bool useif[RIGHT_MAX];
int link[RIGHT_MAX];
//int left_num,right_num;
bool array[LEFT_MAX][RIGHT_MAX];
struct point 
{
   double x;
   double y;
};
bool can(int t,int m)
{
	int i;
	
	for(i=0;i<m;i++)
	{
		if(!useif[i]&&array[t][i])
		{
			useif[i]=true;
			if(link[i]==-1||can(link[i],m))
			{
				link[i]=t;
				return true;
			}
		}

	}
	return false;
}
int main()
{
	int n,m,s,v;
	int distance;
	
	while(cin>>n>>m>>s>>v&&n!=-1)
	{
	point a[110];
	point b[110];
	 memset(link,-1,sizeof(link));
		memset(array,0,sizeof(array));
        memset(useif,0,sizeof(useif));
	int d[110];
	int m1=0,n1=0;
    distance=s*v;
     int i,j;
     for(i=0;i<n;i++)
		 cin>>a[i].x>>a[i].y;
	 for(i=0;i<m;i++)
		 cin>>b[i].x>>b[i].y;
	 int num=0;
	 for(i=0;i<n;i++)
	 {
	    for(j=0;j<m;j++)
		{
		   if((a[i].x-b[j].y)*(a[i].x-b[j].x)+(a[i].y-b[j].y)*(a[i].y-b[j].y)<=distance*distance)
		   {
		      array[i][j]=1;
		   }
		   else
			   array[i][j]=0;
		}
	 }

	 for(i=0;i<n;i++)
		{
			memset(useif,0,sizeof(useif));
			if(can(i,m))
				num++;
		}

	  cout<<n-num<<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