Submission #436763

#TimeUsernameProblemLanguageResultExecution timeMemory
436763TangentGame (IOI14_game)C++17
42 / 100
1100 ms12632 KiB
#include "game.h" #include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vii; typedef vector<ll> vll; typedef vector<pii> vpii; typedef vector<pll> vpll; typedef vector<vii> vvii; typedef vector<vll> vvll; typedef vector<vpii> vvpii; typedef vector<vpll> vvpll; #define ffor(i, a, b) for (ll i = (a); i < (ll)(b); i++) #define fford(i, a, b) for (ll i = (a); i > (ll)(b); i--) #define rep(i, n) ffor(i, 0, n) #define forin(x, a) for (auto &x: a) #define all(a) a.begin(), a.end() int n; vector<set<int>> adj; int queries; void initialize(int N) { queries = 0; n = N; adj.assign(n, {}); rep(i, n - 1) { ffor(j, i + 1, n) { adj[i].emplace(j); adj[j].emplace(i); } } } int hasEdge(int u, int v) { adj[u].erase(v); vector<bool> vis(n); int cnt = 1; vis[u] = true; deque<int> q = {u}; while (!q.empty()) { int uu = q.front(); q.pop_front(); forin(vv, adj[uu]) { if (!vis[vv]) { vis[vv] = true; cnt++; q.emplace_back(vv); } } } if (cnt == n) { adj[v].erase(u); return 0; } else { adj[u].emplace(v); return 1; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...