This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |