Problem description James and gardon are playing a game: For an N * m board, place as many "cars" as possible in the grid as possible in chess ", this makes it easy for them not to attack each other, But gardon restricts that only some grids can be placed. xiaoxi easily solves this problem (see) note that the locations where vehicles cannot be placed do not affect the mutual attack of vehicles.
So gardon wants to solve a more difficult problem. While there are as many "cars" as possible, some grids in the board can be avoided. That is to say, if you do not place a car on these grids, you can also ensure that as many "cars" as possible are put down. However, if some grids are left empty, they cannot be placed as many "cars" as possible. Such grids are called important points. Gardon wants John to figure out how many important points are there. Can you solve this problem?
The input contains multiple groups of data,
The first line contains three numbers: n, m, and K (1 <n, m <= 100 1 <k <= N * m), indicating the height and width of the Board, and the number of grids that can be placed with "cars. The next K lines describe the information of all grids: each row contains two numbers x and y, indicating the position of the grid in the checker.
Output:
Board t have C important blanks for L chessmen.
Sample Input
3 3 41 21 32 12 23 3 41 21 32 13 2
Sample output
Board 1 have 0 important blanks for 2 chessmen. board 2 have 3 important blanks for 3 chessmen. people who have played chess know that a car can go straight through the board. If there are no chess pieces, this is covered. The maximum number of vehicles allowed. Group T data,Delete the edge to see if the maximum number of matching changes. If it is changed, this is an important point. l is the maximum number of vehicles that can be placed.
#include<stdio.h>#include<string.h>int map[105][105],vist[105],match[2][105],m;int find(int i,int k){ for(int j=1;j<=m;j++) if(vist[j]==0&&map[i][j]) { vist[j]=1; if(match[k][j]==0||find(match[k][j],k)) { match[k][j]=i; return 1; } } return 0;}int main(){ int n,k,x,y,C,ans,t=0; while(scanf("%d%d%d",&n,&m,&k)>0) { memset(map,0,sizeof(map)); while(k--) { scanf("%d%d",&x,&y); map[x][y]=1; } memset(match,0,sizeof(match)); ans=0; for(int i=1;i<=n;i++) { memset(vist,0,sizeof(vist)); ans+=find(i,0); } C=ans; for(int j=1;j<=m;j++) if(match[0][j]) { for(int i=1;i<=m;i++) match[1][i]=match[0][i],vist[i]=0; int u=match[0][j]; match[1][j]=0; map[u][j]=0; if(find(u,1))C--; map[u][j]=1; } printf("Board %d have %d important blanks for %d chessmen.\n",++t,C,ans); }}