Title Link: http://www.lightoj.com/volume_showproblem.php?problem=1184
According to some requirements to build a map can
Code:
#include <iostream>#include <algorithm>#include <set>#include <map>#include <string.h>#include <queue>#include <sstream>#include <stdio.h>#include <math.h>#include <stdlib.h>using namespace STD;intN, M;intp[ +][ +];intbook[ +];intmatch[ +];intDfsintu) {intI for(i =1; I <= m; i++) {if(Book[i] = =0&& P[u][i] = =1) {Book[i] =1;if(Match[i] = =0|| DFS (Match[i])) {Match[i] = u;return 1; } } }return 0;}structpeo{intHigintAgeintOK;} a[ the], b[ the];intMain () {intTintCases =1;scanf("%d", &t); while(t--) {scanf("%d%d", &n, &m); for(inti =1; I <= N; i++)scanf("%d%d%d", &a[i].hig, &a[i].age, &a[i].ok); for(inti =1; I <= m; i++)scanf("%d%d%d", &b[i].hig, &b[i].age, &b[i].ok);intAns =0;memset(Match,0,sizeof(match));memset(P,0,sizeof(p)); for(inti =1; I <= N; i++) for(intj =1; J <= M; J + +) {if(A[i].ok = = B[j].ok &&ABS(A[i].hig-b[j].hig) <= A&&ABS(a[i].age-b[j].age) <=5) P[i][j] =1; } for(inti =1; I <= N; i++) {memset(Book,0,sizeof(book));if(Dfs (i)) ans++; }printf("Case%d:%d\n", cases++, ans); }return 0;}
Copyright NOTICE: Reprint please indicate the source.
Lightoj 1184-marriage Media "binary graph Max Match"