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

why???

Posted by fengjian at 2011-08-04 20:49:10 on Problem 1325
In Reply To:没考虑模式0的情况WA了一次…… Posted by:wyc4662 at 2011-07-28 18:16:17
#include<iostream>
using namespace std;
bool map[1001][1001];
bool flag[1001];
int match[1001];
int n,k,m;
bool Dfs(int i)
{
	int j;
	for(j=0;j<m+n;j++)
	{
		if(flag[j]&&map[i][j])
		{
			flag[j]=false;
			if(match[j]==-1||Dfs(match[j]))
			{
				match[j]=i;
				return true;
			}
		}
	}
	return false;
}
int main()
{
	int a,b,i,c;
	int sum,you;
	while(cin>>n,n)
	{
		cin>>m>>k;
		memset(map,false,sizeof(map));
		memset(match,-1,sizeof(match));
		sum=0;
		for(i=0;i<k;i++)
		{
			cin>>a>>b>>c;
			if(b&&c)
			{
			map[a][b]=1;
			map[a][c+n+1]=1;
			}
		}
		for(i=0;i<k;i++)
		{
			memset(flag,true,sizeof(flag));
			if(Dfs(i))
			{
				sum++;
			}
		}
		cout<<k-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