A person, want to see n performances, each performance need to see K times
Now give the weekly schedule for each show, and the closing date of the show
Ask if this guy can finish all the movies.
Problem-solving ideas: Two-figure multi-match can be done, the maximum flow can also be done, here only the binary graph maximum matching
350 days is set to a point set, each show is set to another point set, the capacity is to see the number of times, the relationship between the day is whether there is a performance
#include <cstdio>#include <cstring>#include <algorithm>using namespace STD;#define N#define M 10010#define Sintday[7], G[n][s], Vlink[s], link[s][n], cap[s];intN, tot, Sum;BOOLVis[n], route[s];voidInit () {memset(Vis,0,sizeof(VIS));memset(g,0,sizeof(g));memset(Vlink,0,sizeof(Vlink)); tot =0;scanf("%d", &n);intD, W; Sum =0; for(inti =0; I < n; i++) { for(intj =0; J <7; J + +) {scanf("%d", &day[j]); }scanf("%d%d", &cap[i], &w); Sum + = Cap[i]; for(intj =0; J <7; J + +) {if(Day[j]) { for(intK =0; K < W; k++) {G[k *7+ J][i] =true; Vis[k *7+ j] =true; } } } }}BOOLDfsintu) { for(inti =0; I < n; i++) {if(!route[i] && g[u][i]) {Route[i] =true;if(Vlink[i] < cap[i]) {Link[i][++vlink[i]] = u;return true; } for(intj =1; J <= Vlink[i]; J + +) {if(Dfs (Link[i][j])) {Link[i][j] = u;return true; } } } }return false;}voidSolve () {intAns =0; for(inti =0; I < -; i++)if(Vis[i]) {memset(Route,0,sizeof(route));if(Dfs (i)) {ans++; } }if(ans = = Sum)printf("yes\n");Else printf("no\n");}intMain () {intTestscanf("%d", &test); while(test--) {init (); Solve (); }return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
POJ-1698 Alice's Chance (binary graph multiple match)