Main topic
Give a few games, one person will win each game, ask the person who wins the most wins at least how many times.
Ideas
The first two points of the answer, converted into a judgment problem. Observe the topic and notice that only one person wins each game, so this can be the basis for traffic restrictions on the network flow chart.
Specific:
S-> Everyone f: The maximum number of wins for two points.
Everyone--he participated in the match f:1
Every game->t f:1
Each time the maximum flow is judged equal to the match.
CODE
#define _crt_secure_no_warnings#include <queue>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define MAXP 20010#define Maxe 1000010#define S 0#define T (MAXP-1)#define INF 0x3f3f3f3fusing namespace STD;structmaxflow{intHEAD[MAXP], total;int_next[maxe], Aim[maxe], flow[maxe];intDEEP[MAXP];voidReset () {total =1;memset(Head,0,sizeof(head)); }voidADD (intXintYintf) {_next[++total] = head[x]; Aim[total] = y; Flow[total] = f; HEAD[X] = total; }voidInsert (intXintYintf) {Add (x, Y, F); Add (y, X,0); }BOOLBFS () {Static Queue<int>Q while(!q.empty ()) Q.pop ();memset(Deep,0,sizeof(deep)); Deep[s] =1; Q.push (S); while(!q.empty ()) {intx = Q.front (); Q.pop (); for(inti = head[x]; I i = _next[i])if(Flow[i] &&!deep[aim[i]) {Deep[aim[i]] = deep[x] +1; Q.push (Aim[i]);if(Aim[i] = = T)return true; } }return false; }intDinic (intXintf) {if(x = = T)returnFinttemp = f; for(inti = head[x]; I i = _next[i])if(Flow[i] && temp && deep[aim[i]] = = Deep[x] +1) {intaway = Dinic (Aim[i], min (flow[i], temp));if(!away) deep[aim[i]] =0; Flow[i]-= away; flow[i^1] + = away; Temp-= away; }returnF-temp; }}solver;pair<int,int> MATCH[MAXP];intpoints, edges;inline voidBuildgraph (intANS) {solver. Reset (); for(inti =1; I <= points; ++i) Solver. Insert (S, I, ans); for(inti =1; I <= edges; ++i) {solver. Insert (points + I, T,1); Solver. Insert (Match[i].first, points + I,1); Solver. Insert (Match[i].second, points + I,1); }}intMain () {Cin>> points >> edges; for(inti =1; I <= edges; ++i)scanf("%d%d", &match[i].first, &match[i].second);intL =1, r = edges, ans =1; while(L <= R) {intMid = (L + r) >>1; Buildgraph (mid);intMax_flow =0; while(Solver. BFS ()) Max_flow + = Solver. Dinic (S, INF);if(Max_flow = = edges) R = mid-1, ans = mid;ElseL = mid +1; }cout<< ans << Endl;return 0;}
Bzoj 1532 POI 2005 kos-dicing Max Stream + two points