답안 #320571

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
320571 2020-11-09T06:19:18 Z seedkin 로카히아 유적 (FXCUP4_lokahia) C++17
0 / 100
1 ms 748 KB
#include "lokahia.h"
#include <stdio.h>

int root[205]; // who is root?
int select[205]; // able to get mana?
int isRoot[205]; // 1== root 0 == no
int target;

int findRoot(int r, int leaf) {
	if(r == leaf) return select[r];

	int temp = root[leaf];
	select[r] += select[leaf];
	root[leaf] = r;
	select[leaf] = 0;
	isRoot[leaf] = 0;
	// isRoot[r] = 1;

	return temp == -1 ? select[r]: findRoot(r, temp);
}

int FindBase(int N){
	// printf("%d\n", CollectRelics(0, 1));
	target = N / 2;

	for(int i =0;i < N; i++) {
		root[i] = -1;
		select[i] = 1;
		isRoot[i] = 1;
	}

	if(N % 2) isRoot[N-1] = 1;

	// for(int i =0; i+1 < N; i+=2) {
	// 	int r = CollectRelics(i, i+1);
	// 	if( r == -1) {
	// 		isRoot[i] = 1;
	// 		isRoot[i+1] = 1;
	// 		continue;
	// 	}
	// 	int num = findRoot(r, i);		
	// 	num = findRoot(r, i+1);
	// 	if(num >= target) return r;		
	// }

	for(int i =0; i < N; i++) {
		if(isRoot[i] ==0) continue;
		for(int j = i+1; j< N; j++) {
			if(isRoot[j] == 0) continue;
			int one = i;
			int two = j;
			int r = CollectRelics(one, two);
			if( r == -1) {
				isRoot[one] = 1;
				isRoot[two] = 1;
				continue;
			}
			int num = findRoot(r, one);		
			num = findRoot(r, two);
			if(num >= target) return r;		
		}
	}

	// for(int i =0; i< N; i++) {
	// 	printf("node: %d select: %d\n", i, select[i]);
	// }
	return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 620 KB Wrong
2 Incorrect 1 ms 620 KB Wrong
3 Correct 1 ms 620 KB Correct : C = 58
4 Correct 1 ms 492 KB Correct : C = 101
5 Correct 1 ms 620 KB Correct : C = 116
6 Partially correct 1 ms 620 KB Partially correct : C = 363
7 Incorrect 1 ms 620 KB Wrong
8 Incorrect 1 ms 620 KB Wrong
9 Incorrect 1 ms 620 KB Wrong
10 Incorrect 1 ms 620 KB Wrong
11 Correct 1 ms 620 KB Correct : C = 197
12 Incorrect 1 ms 620 KB Wrong
13 Incorrect 1 ms 620 KB Wrong
14 Correct 1 ms 620 KB Correct : C = 59
15 Incorrect 1 ms 620 KB Wrong
16 Correct 1 ms 620 KB Correct : C = 118
17 Correct 1 ms 492 KB Correct : C = 1
18 Correct 1 ms 620 KB Correct : C = 117
19 Incorrect 1 ms 620 KB Wrong
20 Incorrect 1 ms 620 KB Wrong
21 Correct 1 ms 620 KB Correct : C = 169
22 Correct 1 ms 620 KB Correct : C = 99
23 Incorrect 1 ms 620 KB Wrong
24 Correct 1 ms 748 KB Correct : C = 98
25 Correct 1 ms 620 KB Correct : C = 168
26 Incorrect 0 ms 492 KB Wrong
27 Correct 1 ms 620 KB Correct : C = 197