이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "game.h"
using namespace std;
int a[35005],p[35005];
int P(int x) {
if (p[x]==x) return x;
return p[x]=P(p[x]);
}
void Uni(int a,int b) {
a=P(a);
b=P(b);
p[b]=a;
}
void initialize(int n) {
for (int i=1; i<=n; i++)
p[i]=i,a[i]=n-1;
}
int hasEdge(int u,int v) {
u++,v++;
if (P(u)==P(v)){
a[u]--,a[v]--;
return 1;
}
if (a[u]==1 || a[v]==1) {
Uni(u,v);
if (a[u]) a[u]--;
if (a[v]) a[v]--;
return 1;
}
a[u]--,a[v]--;
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... |