Submission #588236

#TimeUsernameProblemLanguageResultExecution timeMemory
588236AlperenTGame (IOI14_game)C++17
100 / 100
350 ms20472 KiB
#include <bits/stdc++.h> #include "game.h" using namespace std; const int N = 1500 + 5; int n, cnt[N][N]; struct DSU{ int par[N], setcnt; void init(int n){ for(int i = 0; i < n; i++) par[i] = i; } int setfind(int a){ if(a == par[a]) return a; else return par[a] = setfind(par[a]); } void setunion(int a, int b){ par[b] = par[a]; for(int v = 0; v < n; v++) cnt[min(a, v)][max(a, v)] += cnt[min(b, v)][max(b, v)]; } }; DSU dsu; void initialize(int N){ n = N; dsu.init(n); for(int i = 0; i < n; i++){ for(int j = i + 1; j < n; j++){ cnt[i][j] = 1; } } } int hasEdge(int u, int v) { u = dsu.setfind(u), v = dsu.setfind(v); if(v < u) swap(v, u); if(u == v) return 1; else{ cnt[u][v]--; if(cnt[u][v] == 0){ dsu.setunion(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...