Submission #250405

#TimeUsernameProblemLanguageResultExecution timeMemory
250405ernestvwGame (IOI14_game)C++11
0 / 100
5 ms4224 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define sz(x) ((int)x.size()) #define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); int N = 0; int cc = 0, k = 0; int p[2000]; bool arc[2000][2000]; int find(int u) { return p[u] == u ? u : (p[u] = find(p[u])); } void merge(int u, int v) { if(find(u) == find(v)) return; --cc; memset(arc, false, sizeof(arc)); p[find(u)] = find(v); } void initialize(int n) { N = n; cc = n; k = 0; for(int i = 0; i < n; ++i) p[i] = i; } int hasEdge(int u, int v) { ++k; arc[u][v] = arc[v][u] = 1; if(k == (N * (N-1)) / 2) return 1; if(find(u) == find(v)) return 1; bool ok = 1; for(int i = 0; i < N; ++i) if(find(i) == find(v)) { if(!arc[i][u]) { ok = 0; break; } } if(ok) merge(u, v); return ok; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...