답안 #47900

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
47900 2018-05-08T13:32:27 Z robert CEOI16_icc (CEOI16_icc) C++14
7 / 100
380 ms 992 KB
#include "icc.h"

using namespace std;

const int MAXN = 110;

int UFDS[MAXN];

int p(int n){
	if(UFDS[n]==n)
		return n;
	else
		return UFDS[n] = p(UFDS[n]);
}

int merge(int i, int j){
	return UFDS[p(i)] = p(j);
}

int N;

void findRoad(){
	for(int i=1; i<=N; i++){
	//	if(UFDS[i]==i){
			for(int j=i+1; j<=N; j++){
				if(p(j)!=p(i)){
					//both i and j are leaders of their group
/*					int *f = new int[110], *s = new int[110];
					int fs=0, ss=0;
					for(int x=1; x<=N; x++){
						if(p(x)==i){
							f[fs++] = x;
						} else if(p(x)==j){
							s[ss++] = x;
						}
					}
					if(query(fs, ss, f, s)){
						//found between which two sets a road has been built
						merge(i, j);
						setRoad
					}
*/					int f[] = {i}, s[] = {j};
					if(query(1, 1, f, s)){
						merge(i, j);
						setRoad(i, j);
						return;
					}
				}
			}
	//	}
	}
}

void run(int NN){
	N = NN;
	for(int n=0; n<=N; n++){
		UFDS[n] = n;
	}
	for(int n=1; n<N; n++)
		findRoad();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 70 ms 504 KB Ok! 1015 queries used.
2 Correct 67 ms 744 KB Ok! 1010 queries used.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 361 ms 744 KB Number of queries more than 5000 out of 2500
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 380 ms 900 KB Number of queries more than 4500 out of 2250
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 341 ms 948 KB Number of queries more than 4000 out of 2000
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 303 ms 988 KB Number of queries more than 3550 out of 1775
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 276 ms 992 KB Number of queries more than 3250 out of 1625
2 Halted 0 ms 0 KB -