Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 删掉，或者不扫0,0，的边。

Posted by yinjian at 2016-08-11 16:15:25 on Problem 1325
```#include <stdio.h>
#include <string.h>

int n,m,k;
bool maps[105][105];
int match[1050];
bool use[1050];

bool DFS(int u)
{
for(int i=1;i<m;i++)
{
if(!use[i]&&maps[u][i])
{
use[i] = true;
if(match[i]==-1||DFS(match[i]))
{
match[i] = u;
return true;
}
}
}
return false;
}

int main()
{
while(scanf("%d",&n))
{
if(n==0) break;
scanf("%d%d",&m,&k);
memset(maps,false,sizeof(maps));
memset(match,-1,sizeof(match));

for(int i=0;i<k;i++)
{
int t,a,b;
scanf("%d%d%d",&t,&a,&b);
maps[a][b] = true;
}
/*for(int i=0;i<m;i++)
{
if(maps[0][i])
maps[0][i] = false;
}
for(int i=0;i<n;i++)
{
if(maps[i][0])
maps[i][0] = false;
}*/
int num = 0;
for(int i=1;i<n;i++)
{
memset(use,false,sizeof(use));
if(DFS(i))
num++;
}
printf("%d\n",num);
}
return 0;
}
```

Followed by: