Submission #835771

#TimeUsernameProblemLanguageResultExecution timeMemory
835771LoboGame (IOI14_game)C++17
100 / 100
287 ms25260 KiB
#include "game.h" #include<bits/stdc++.h> using namespace std; #define pb push_back #define fr first #define sc second const int maxn = 1510; int n, ds[maxn], dsz[maxn]; int ask[maxn][maxn]; int find(int v) { if(v == ds[v]) return v; return ds[v] = find(ds[v]); } void join(int u, int v) { if(dsz[u] < dsz[v]) swap(u,v); dsz[u]+= dsz[v]; for(int x = 0; x < n; x++) { ask[u][x]+= ask[v][x]; ask[x][u]+= ask[x][v]; } ds[v] = u; } void initialize(int N) { n = N; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(i != j) { ask[i][j] = 1; ask[j][i] = 1; } } } for(int i = 0; i < n; i++) { ds[i] = i; dsz[i] = 1; } } int hasEdge(int u, int v) { u = find(u); v = find(v); ask[u][v]--; ask[v][u]--; if(find(u) == find(v)) return 0; // assert(u != v); if(ask[u][v] == 0) { join(u,v); return 1; } else { return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...