Advertisement
999ms

Untitled

Nov 6th, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. const int MSIZE = 500 * 500;
  2. const int delta = 500;
  3. vector<int> g[MSIZE];
  4. bool used[MSIZE];
  5. int mt[MSIZE];
  6.  
  7. int inc(int v) {
  8.     if (used[v]) return false;
  9.     used[v] = true;
  10.     for (int nxt : g[v]) {
  11.         if (mt[nxt] == -1) {
  12.             mt[nxt] = v;
  13.             return true;
  14.         }
  15.     }
  16.     for (int nxt : g[v]) {
  17.         if (inc(mt[nxt])) {
  18.             mt[nxt] = v;
  19.             return true;
  20.         }
  21.     }
  22.     return false;
  23. }
  24.  
  25. void GetMT(pair<int,vector<int> > * kek) {
  26.     memset(used, 0, sizeof used);
  27.     fill(mt, mt + MSIZE, -1);
  28.     int ans = 0;
  29.     for (int i = 0; i < MSIZE; i++) {
  30.         if (inc(i)) {
  31.             memset(used, 0, sizeof used);
  32.             ans++;
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement