Submission #520110

#TimeUsernameProblemLanguageResultExecution timeMemory
520110tjd229Game (IOI14_game)C++14
100 / 100
408 ms25104 KiB
#include "game.h" int n; int p[1500]; int mat[1500][1500]; int sz[1500]; int find(int a) { if (p[a] != a) p[a] = find(p[a]); return p[a]; } bool dsu(int a, int b) { a = find(a); b = find(b); if (a == b) return false; sz[a] += sz[b]; for (int i = 0; i < n; ++i) { int par = find(i); mat[i][a] += mat[i][b]; mat[a][i] += mat[b][i]; } p[b] = a; return true; } void initialize(int n) { ::n = n; for (int i = 0; i < n; ++i) { sz[i] = 1; p[i] = i; } } int hasEdge(int u, int v) { int U = find(u), V = find(v); if (U == V) return 0; ++mat[U][V]; ++mat[V][U]; if (sz[U] * sz[V] == mat[U][V]) { dsu(U, V); return 1; } return 0; }

Compilation message (stderr)

game.cpp: In function 'bool dsu(int, int)':
game.cpp:16:7: warning: unused variable 'par' [-Wunused-variable]
   16 |   int par = find(i);
      |       ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...