Submission #678001

#TimeUsernameProblemLanguageResultExecution timeMemory
678001Hacv16Game (IOI14_game)C++17
100 / 100
348 ms25492 KiB
#include <bits/stdc++.h> #include "game.h" using namespace std; const int MAX = 1550; int n, pai[MAX], sze[MAX], f[MAX][MAX]; int find(int u){ return pai[u] = (pai[u] == u ? u : find(pai[u])); } void join(int u, int v){ u = find(u), v = find(v); if(u == v) return; if(sze[v] > sze[u]) swap(u, v); pai[v] = u; sze[u] += sze[v]; for(int i = 1; i <= n; i++) f[u][i] += f[v][i], f[i][u] += f[v][i]; } void initialize(int _n){ n = _n; for(int i = 1; i <= n; i++){ pai[i] = i; sze[i] = 1; for(int j = i + 1; j <= n; j++) f[i][j] = f[j][i] = 1; } } int hasEdge(int u, int v){ u++, v++; u = find(u), v = find(v); if(u == v) return 0; if(f[u][v] == 1){ join(u, v); return 1; } f[u][v]--, f[v][u]--; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...