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<set<int>>pos;
void initialize(int n) {
pos.resize(n);
for (int i = 0;i<n;++i){
for (int j = 0;j<n;++j){
if (i != j){
pos[i].insert(j);
}
}
}
}
int hasEdge(int u, int v) {
auto join = [&](int a,int b){
vector<int>temp;
for (auto x:pos[a]){
if (pos[b].find(x) != pos[b].end()){
temp.push_back(x);
}
}
for (auto x:pos[b]){
if (pos[a].find(x) != pos[a].end()){
temp.push_back(x);
}
}
for (auto x:temp){
if (pos[a].find(x)!=pos[a].end()){
pos[a].erase(x);
}
if (pos[b].find(x)!=pos[b].end()){
pos[b].erase(x);
}
}
};
if (pos[u].size() == 1 || pos[v].size() == 1){
join(u,v);
return 1;
}
if (pos[u].find(v)!=pos[u].end()){
pos[u].erase(v);
}
if (pos[v].find(u)!=pos[v].end()){
pos[v].erase(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... |