Submission #824238

#TimeUsernameProblemLanguageResultExecution timeMemory
824238rnl42Game (IOI14_game)C++14
0 / 100
1 ms212 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; vector<int> uf; int root(int u) { return u == uf[u] ? u : uf[u] = root(uf[u]); } void merge(int u, int v) { uf[root(u)] = root(v); } int N; vector<vector<int>> madj; void initialize(int __N) { N = __N; madj.assign(N, vector<int>(N, -1)); uf.resize(N); iota(uf.begin(), uf.end(), 0); } int hasEdge(int u, int v) { bool choice = true; for (int i = 0; i < N; i++) { if (u != i && v != i && madj[u][i] == -1 && (root(i) == root(v) || root(i) == root(u))) { choice = false; } if (u != i && v != i && madj[v][i] == -1 && (root(i) == root(v) || root(i) == root(u))) { choice = false; } } madj[u][v] = madj[v][u] = choice; if (choice) { merge(u, v); } return choice; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...