Submission #393456

#TimeUsernameProblemLanguageResultExecution timeMemory
393456peuchGame (IOI14_game)C++17
0 / 100
1 ms336 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN = 1510; int N; int rep[MAXN], tam[MAXN]; int conect[MAXN][MAXN]; int find(int a){ if(rep[a] == a) return a; return rep[a] = find(rep[a]); } void uni(int a, int b){ a = find(a); b = find(b); if(tam[a] < tam[b]) swap(a, b); rep[b] = a; tam[a] += b; for(int i = 0; i < N; i++) conect[a][i] = conect[a][i] + conect[b][i], conect[i][a] = conect[a][i] + conect[b][i]; } void initialize(int n) { N = n; for(int i = 0; i < N; i++){ rep[i] = i; tam[i] = 1; for(int j = 0; j < N; j++) conect[i][j] = 1; conect[i][i] = 0; } } int hasEdge(int u, int v) { u = find(u), v = find(v); if(conect[u][v] == 1){ uni(u, v); return 1; } conect[u][v]--; conect[v][u]--; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...