답안 #38901

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
38901 2018-01-07T18:19:23 Z adamczh1 게임 (IOI14_game) C++14
0 / 100
0 ms 10808 KB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
struct UnionFind {
	vector<int> data;
	int compcnt;
	void init(int n) { data.assign(n, -1), compcnt=n; }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
			compcnt--;
		}
		return x != y;
	}
	bool findSet(int x, int y) { return root(x) == root(y); }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	int size(int x) { return -data[root(x)]; }
} uf;
void initialize(int n) {
	uf.init(n);
}

int hasEdge(int u, int v) {
	if(!uf.findSet(u,v) && uf.compcnt>2){
		uf.unionSet(u,v);
		return 1;
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 10808 KB Output is correct
2 Incorrect 0 ms 10808 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 10808 KB Output is correct
2 Incorrect 0 ms 10808 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 10808 KB Output is correct
2 Incorrect 0 ms 10808 KB Output isn't correct
3 Halted 0 ms 0 KB -