Submission #997404

#TimeUsernameProblemLanguageResultExecution timeMemory
997404daffuwuGame (IOI14_game)C++14
42 / 100
1095 ms4740 KiB
#include <bits/stdc++.h> #include "game.h" using namespace std; int n, rep[1569]; bool ex[1569][1569]; int fd(int x) { if (rep[x] != x) rep[x] = fd(rep[x]); return rep[x]; } void initialize(int n) { ::n = n; int i, j; for (i=0; i<=n-1; i++) { for (j=i+1; j<=n-1; j++) ex[i][j] = 1; } } int hasEdge(int u, int v) { int i, j; if (u>v) swap(u, v); ex[u][v] = 0; for (i=0; i<=n-1; i++) rep[i] = i; for (i=0; i<=n-1; i++) { for (j=i+1; j<=n; j++) { if (ex[i][j]) rep[fd(i)] = fd(j); } } if (fd(u) != fd(v)) ex[u][v] = 1; return ex[u][v]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...