Submission #763444

#TimeUsernameProblemLanguageResultExecution timeMemory
763444adrilenGame (IOI14_game)C++17
100 / 100
295 ms16692 KiB
#include "game.h" #include<bits/stdc++.h> using namespace std; using ll = long long; typedef pair<int, int> pii; constexpr int maxn = 1.5e3; bitset <maxn> guessed[maxn]; int group[maxn]; basic_string<int> groups[maxn]; void initialize(int n) { for (int i = 0; i < n; i++) { group[i] = i; groups[i].push_back(i); } } int hasEdge(int u, int v) { int a = group[u], b = group[v]; guessed[u][v] = guessed[v][u] = true; for (const int &i : groups[a]) { for (const int &y : groups[b]) { if (!guessed[i][y]) { // Do not make a change return 0; } } } // Connect the groups if (groups[a].size() < groups[b].size()) swap(a, b); groups[a].insert(groups[a].end(), groups[b].begin(), groups[b].end()); for (const int &i : groups[b]) group[i] = a; return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...