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 <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
vector<vector<int>> G;
vector<bool> used;
int n;
void dfs(int v){
used[v] = 1;
for (int i: G[v]){
if (!used[i]){
dfs(i);
}
}
}
int hasEdge(int u, int v){
auto it = find(G[u].begin(), G[u].end(), v);
G[u].erase(it);
it = find(G[v].begin(), G[v].end(), u);
G[v].erase(it);
fill(used.begin(), used.end(), 0);
dfs(0);
for (int i = 0; i < n; i++){
if (!used[i]){
G[u].pb(v);
G[v].pb(u);
return 1;
}
}
return 0;
}
void initialize(int N){
n = N;
used.resize(n);
G.resize(n);
for (int i = 0; i < n; i++){
for (int j = i + 1; j < n; j++){
G[i].pb(j);
G[j].pb(i);
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |