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

怎么我不用这个构图也能AC啊????

Posted by zsc08_wangqiang at 2010-09-04 20:45:03 on Problem 1325
不用if(x * y != 0) map[x][y] = 1; 也能AC 的?

#include<iostream>
using namespace std;

#define maxn 1000

int N, M, uN;
bool g[maxn][maxn];
int xM[maxn], yM[maxn];
bool chk[maxn];

bool find(int u)
{
	int v;
	for(v=1; v<=M; v++)
		if(g[u][v] && !chk[v])
		{
			chk[v] = true;
			if(yM[v] == -1 || find(yM[v]))
			{
				yM[v] = u;
				xM[u] = v;
				return true;
			}
		}
	return false;
}

int MaxMatch()
{
	int u, ret = 0;
	memset(xM, -1, sizeof(xM));
	memset(yM, -1, sizeof(yM));
	for(u= 1;u<=N; u++)
	{
		if(xM[u] == -1)
		{
			memset(chk, false, sizeof(chk));
			if(find(u)) ret++;
		}
	}
	return ret;
}

int main()
{
	int i, id, k, x, y, res;
	while(scanf("%d%d%d",&N, &M, &k) && N)
	{
		memset(g, 0, sizeof(g));
		for(i=0; i<k; i++)
		{
			scanf("%d%d%d",&id, &x, &y);
			//if(x * y != 0)
				g[x][y] = 1;
		}	
		//uN = N;
		res = MaxMatch();
		printf("%d\n",res);
	}
	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