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 <vector>
#include <algorithm>
using namespace std;
int n;
vector<int> edge[1500];
int num[1500], low[1500];
int vis[1500];
int stamp,k;
void initialize(int n) {
::n = n;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
if(i!=j)
edge[i].push_back(j);
}
}
}
void dfs(int x,int from,int stamp) {
num[x] =low[x]= k++; vis[x] = stamp;
for (auto nxt : edge[x]) {
if (nxt == from) continue;
if (vis[nxt] != stamp) {
dfs(nxt, x, stamp);
low[x] = min(low[x], low[nxt]);
}
else {
low[x] = min(low[x], num[nxt]);
}
}
}
void rm(vector<int> &v, int x) {
for (auto &y : v) {
if (y == x) {
y = v.back();
v.pop_back();
return;
}
}
}
int hasEdge(int u, int v) {
k = 0;
dfs(1, -1, ++stamp);
if (num[u] > num[v]) u ^= v ^= u ^= v;
if (low[v] > num[u]) return 1;
rm(edge[u], v); rm(edge[v], u);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |