Submission #250406

#TimeUsernameProblemLanguageResultExecution timeMemory
250406ernestvwGame (IOI14_game)C++11
0 / 100
4 ms4352 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) { arc[u][v] = arc[v][u] = 1; if(find(u) == find(v)) return 1; int ok = 1; for(int i = 0; i < N; ++i) if((find(i) == find(v) && !arc[i][u]) || (find(i) == find(u) && !arc[i][v])) ok = 0; 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...