This konjac Konjac of mine is also going to start to do the network flow AH Qwq
Problem of pilot pairing scheme
Binary map Matching * * Problem , Hungary can
1#include <bits/stdc++.h>2 using namespacestd;3 BOOLvis[101];4 intmatch[101], head[101], CNT;5 structedge{6 intend, uped;7}ed[10001];8InlinevoidAddintAintb) {9Ed[++cnt].end = b; ed[cnt].uped = Head[a]; Head[a] =CNT;Ten } One BOOLDfsinta) { A for(inti = Head[a]; I i =ed[i].uped) - if(!Vis[ed[i].end]) { -Vis[ed[i].end] =1; the if(!match[ed[i].end] | |DFS (Match[ed[i].end])) { -Match[ed[i].end] =A; - return 1; - } + } - return 0; + } A intMain () { at intM, N, ans =0, A, b; -scanf"%d%d%d%d", &m, &n, &a, &b); - while(A! =-1){ -Add (A, B-M); -scanf"%d%d", &a, &b); - } in for(inti =1; I <= M; i++){ -memset (Vis,0,sizeof(Vis)); to DFS (i); + } - for(inti =1; i + M <= N; i++) ans + = (BOOL) match[i]; the if(ans = =0) cout <<"No solution!"; * Else{ $cout << ans <<Endl;Panax Notoginseng for(inti =1; i + M <= N; i++) - if(Match[i]) cout << Match[i] <<' '<< i + M <<Endl; the } + return 0; A}
Load Balancing Issues
Round-the-loop card Dafa roar.
1#include <bits/stdc++.h>2 using namespacestd;3InlineintRead () {4 intA =0;5 Charc =GetChar ();6 while(!isdigit (c)) C =GetChar ();7 while(IsDigit (c)) A = (a <<3) + (a <<1) + (c ^'0'), C =GetChar ();8 returnA;9 }TenInlineintAbsinta) { One returnA >0? A:-A; A } - Long Longs[1000001]; - intMain () { the intn =read (); - Long Longsum =0; - for(inti =1; I <= N; i++) -Sum + = s[i] =read (); +Sum/=N; - for(inti =1; I <= N; i++) +S[i] + = s[i-1] -sum; ASort (S +1, S + n +1); atsum =0; - for(inti =1; I <= N; i++) -Sum + = ABS (S[i]-s[n +1>>1]); -printf"%lld", sum); - return 0; -}
Network Flow 24 Questions 2/24