Network Flow 24 Questions 2/24

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.