Submission #235066

#TimeUsernameProblemLanguageResultExecution timeMemory
235066anonymousGame (IOI14_game)C++14
0 / 100
5 ms384 KiB
#include "game.h" #include <iostream> #define MAXN 1505 using namespace std; int Cmp, Num, N; class DSU { public: int Set[MAXN]; void init(int n) { for (int i=0; i<=n; i++) {Set[i] = i;} } int Find(int x) { return(Set[x] == x ? x : Set[x] = Find(Set[x])); } void Union(int x, int y) { int p1 = Find(x), p2 = Find(y); Set[p1] = p2; if (p1 != p2) {Cmp--;} } } UF; void initialize(int n) { UF.init(n), N=n; Cmp = N; } int hasEdge(int u, int v) { Num++; if (Cmp > 2 || 2*Num == N*(N-1)) { UF.Union(u,v); return(1); } return(0); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...