답안 #320823

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
320823 2020-11-10T03:54:04 Z seedkin 로카히아 유적 (FXCUP4_lokahia) C++17
0 / 100
1000 ms 620 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 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;	

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

int FindBase(int N){	
	int target = N / 2;	
	int boss[205];
	int bossNum = 0;
	
	for(int i =0; i < N; i++) {
		root[i] = -1;
		select[i] = 1;
		isRoot[i] = 1;
		boss[i] = 0;
	}

	for(int i =0; i< N;) {
		int s = 1;
		boss[bossNum++] = i;
		for(int j =i+1; j < N; j++) {
			int r = CollectRelics(i, j);
			if( r == -1) {
				s--;
				if(s == 0) {
					i = j+1;
					break;
				}
				continue;
			}
			int num = findRoot(r, i);
			num = findRoot(r,j);
			if(num > target) return r;
			s++;
		}
	}
	
	int c = boss[bossNum-1];

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

	// for(int i =0; i < bossNum-1; i++) {
	// 	int a = boss[i];
	// 	if(root[c] == root[a] && root[c] != -1) continue;
	// 	int r = CollectRelics(c, a);
	// 	if(r == -1) {
	// 		int b = boss[i+1];
	// 		for(int j = a+1; j < b; j++) {
	// 			if(root[c] == root[j] && root[c] != -1) continue;
	// 			if(isRoot[j] == 0) continue;
	// 			r = CollectRelics(c, j);
	// 			if(r == -1) continue;
	// 			int num = findRoot(r, c);
	// 			num = findRoot(r, j);
	// 			if(num > target) return r;
	// 		}
	// 		continue;
	// 	}
	// 	int num = findRoot(r, c);
	// 	num = findRoot(r, a);
	// 	if(num > target) return r;
	// }

	if(root[c] == -1 && select[c] > target ) return c;
	else if(root[c] != -1 && select[root[c]] > target) return root[c];
	return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1053 ms 492 KB Time limit exceeded
2 Execution timed out 1094 ms 492 KB Time limit exceeded
3 Incorrect 1 ms 620 KB Wrong
4 Incorrect 1 ms 620 KB Wrong
5 Execution timed out 1089 ms 620 KB Time limit exceeded
6 Incorrect 1 ms 620 KB Wrong
7 Correct 1 ms 492 KB Correct : C = 2
8 Correct 2 ms 620 KB Correct : C = 100
9 Incorrect 1 ms 620 KB Wrong
10 Correct 1 ms 620 KB Correct : C = 191
11 Correct 1 ms 620 KB Correct : C = 100
12 Execution timed out 1083 ms 620 KB Time limit exceeded
13 Correct 1 ms 620 KB Correct : C = 169
14 Incorrect 1 ms 620 KB Wrong
15 Correct 1 ms 620 KB Correct : C = 99
16 Execution timed out 1056 ms 620 KB Time limit exceeded
17 Correct 1 ms 620 KB Correct : C = 171
18 Correct 1 ms 620 KB Correct : C = 103
19 Incorrect 1 ms 620 KB Wrong
20 Incorrect 1 ms 620 KB Wrong
21 Execution timed out 1082 ms 492 KB Time limit exceeded
22 Incorrect 1 ms 620 KB Wrong
23 Correct 1 ms 620 KB Correct : C = 111
24 Correct 1 ms 620 KB Correct : C = 60
25 Correct 1 ms 620 KB Correct : C = 59
26 Incorrect 1 ms 620 KB Wrong
27 Correct 1 ms 620 KB Correct : C = 60