이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int par[1505], dp[1505][1505];
set<int> rep;
int find(int x) { if(x==par[x])return x;else return par[x]=find(par[x]); }
void merge(int a, int b) { 
	a = find(a), b = find(b); if(a==b)return;
	rep.erase(a);
	for(auto it : rep) dp[b][it] = dp[it][b] = dp[b][it] + dp[a][it];
	par[a]=b;
}
void initialize(int n){ 
	for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) dp[i][j] = 1; 
	for(int i = 0; i < n; i++) rep.insert(i), par[i]=i;
}
int hasEdge(int u, int v) {
	if(find(u)==find(v)) 
		return 0; 
	if(dp[find(u)][find(v)] == 1) {merge(u,v); return 1;}
	dp[find(u)][find(v)]--, dp[find(v)][find(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... |