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;
vector<int> a;
vector<int> ad[(int)2e3];
bool b = 0;
void hasCycle(int x,int p, int start){
if(x == start && p != -1){
b = 1;
return;
}
for(auto s: ad[x]){
if(s == p) continue;
return hasCycle(s,x,start);
}
}
void initialize(int n) {
a.assign(n+1,n-1);
}
int hasEdge(int u, int v) {
b = 0;
a[u]--;
a[v]--;
if(a[u] == 0 || a[v] == 0){
return 1;
}
hasCycle(u,-1,u);
ad[u].push_back(v);
ad[v].push_back(u);
if(b){
ad[u].erase(find(ad[u].begin(),ad[u].end(),v));
ad[v].erase(find(ad[v].begin(),ad[v].end(),u));
}
return b;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |