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>
#define lb lower_bound
#define LINE "------------\n"
using namespace std;
using PII = pair <int, int>;
const int N = 1500;
// bool path[N][N];
set <int> vals[N];
int n;
int par[N];
void initialize(int _n) {
n = _n;
for (int i = 0; i < n; i++)
for (int j = i+1; j < n; j++) {
vals[i].insert(j);
vals[j].insert(i);
}
for (int i = 0; i < n-1; i++) {
par[i] = n-1;
}
}
int hasEdge(int u, int v) {
// cout << LINE;
// cout << u << " " << v << '\n';
// for (int i = 0; i < n-1; i++) cout << i << ": " <<par[i] << '\n';
if (par[u] != v && par[v] != u) {
vals[u].erase(v);
vals[v].erase(u);
return 0;
}
if (par[v] == u) swap(u, v);
bool res = 1;
for (auto& el : vals[u]) {
if (el != par[u] && par[el] != u) {
par[u] = el;
vals[u].erase(v);
vals[v].erase(u);
res = 0;
break;
}
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |