Submission #784391

#TimeUsernameProblemLanguageResultExecution timeMemory
784391qwerasdfzxclGame (IOI14_game)C++17
0 / 100
8 ms468 KiB
#include "game.h" #include <bits/stdc++.h> typedef long long ll; using namespace std; int n; struct DSU{ int path[1515], cnt[1515][1515]; void init(int n){ for (int i=1;i<=n;i++){ path[i] = i; for (int j=1;j<=n;j++) if (i!=j) cnt[i][j] = 1; } } int find(int s){ if (s==path[s]) return s; return path[s] = find(path[s]); } int merge(int s, int v){ s = find(s), v = find(v); assert(s!=v); if (cnt[s][v] > 1){ cnt[s][v]--; cnt[v][s]--; return 0; } path[v] = s; for (int i=1;i<=n;i++) if (find(i)==i && i!=s){ cnt[s][i] += cnt[v][i]; cnt[i][s] = cnt[s][i]; } } }dsu; void initialize(int N) { n = N; dsu.init(n); } int hasEdge(int u, int v) { ++u, ++v; return dsu.merge(u, v); }

Compilation message (stderr)

game.cpp: In member function 'int DSU::merge(int, int)':
game.cpp:37:3: warning: control reaches end of non-void function [-Wreturn-type]
   37 |   }
      |   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...