Submission #928616

#TimeUsernameProblemLanguageResultExecution timeMemory
928616OAleksaGame (IOI14_game)C++14
0 / 100
18 ms36444 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; const int N = 1569; int n, p[N], sz[N], c[N][N]; int root(int v) { if (p[v] == v) return v; return p[v] = root(p[v]); } void initialize(int n1) { n = n1; for (int i = 0;i < n;i++) { p[i] = i, sz[i] = 1; } for (int i = 0;i < n;i++) { for (int j = 0;j < n;j++) { if (i == j) continue; c[i][j] = 1; } } } int hasEdge(int u, int v) { int a = root(u); int b = root(v); if (a == b || c[a][b] > 1) return 1; --c[a][b], --c[b][a]; if (sz[a] < sz[b]) swap(a, b); p[b] = a; sz[a] += sz[b]; for (int i = 0;i < n;i++) { if (i == a || i == b) continue; c[a][i] += c[b][i]; c[i][a] += c[b][i]; } }

Compilation message (stderr)

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