이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |