이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
bool used[80][80];
int n;
int p[80];
int find(int a) {
if (p[a]<0) {
return a;
}
return p[a]=find(p[a]);
}
void merge(int a,int b) {
a=find(a);
b=find(b);
if (a==b){
return;
}
p[a]+=p[b];
p[b]=a;
}
void initialize(int nn) {
n=nn;
}
int hasEdge(int u,int v) {
used[u][v]=true;
used[v][u]=true;
memset(p,-1,sizeof(p));
for(int i=0;i<n;i++) {
for(int j=i+1;j<n;j++) {
if (!used[i][j]) {
merge(i,j);
}
}
}
if (p[find(0)]==-n) {
return false;
}
else {
used[u][v]=false;
used[v][u]=false;
return true;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |