Submission #393458

#TimeUsernameProblemLanguageResultExecution timeMemory
393458peuchGame (IOI14_game)C++17
100 / 100
519 ms15812 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){ if(tam[a] < tam[b]) swap(a, b); rep[b] = a; tam[a] += tam[b]; for(int i = 0; i < N; i++){ conect[a][i] += conect[b][i]; conect[i][a] += conect[i][b]; } } 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; } } int hasEdge(int u, int v) { u = find(u), v = find(v); conect[u][v]--; conect[v][u]--; if(conect[u][v] != 0) return 0; uni(u, v); return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...