답안 #320919

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
320919 2020-11-10T09:02:44 Z seedkin 로카히아 유적 (FXCUP4_lokahia) C++17
0 / 100
4 ms 1260 KB
#include "lokahia.h"
#include <stdio.h>
 
int root[205]; // who is root?
int select[205]; // able to get mana?
 
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;	
 
	return temp == -1 ? select[r]: findRoot(r, temp);
}
 
int getRoot(int n) {
	int r = root[n];
	if(r == -1) return n;
	findRoot(r, n);
	root[n] = getRoot(r);
	return root[n];
}
 
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;		
		boss[i] = 0;
	}
 
	for(int i =0; i< N;) {
		int s = 1;
		boss[bossNum++] = i;
		for(int j =i+1; j < N; j++) {
            if(getRoot(i) == getRoot(j)) continue;
			int r = CollectRelics(getRoot(i), getRoot(j));
			if( r == -1) {
				s--;
				if(s == 0) {
					i = j+1;
					if(i == N) return -1;
					break;
				}
				continue;
			}
			int num = findRoot(getRoot(r), getRoot(i));
			num = findRoot(getRoot(r),getRoot(j));
			if(num > target) return getRoot(r);
			s++;
		}
	}
 
	int c = boss[bossNum-1];
 
	for(int i =0; i < bossNum-1; i++) {
		int a = boss[i];		
        if(getRoot(c) == getRoot(a)) continue;
		int r = CollectRelics(getRoot(c), getRoot(a));
		if(r == -1) {
			int b = boss[i+1];
			for(int j = a+1; j < b; j++) {
                if(getRoot(c) == getRoot(j)) continue;
				if(getRoot(j) != j) continue;
				r = CollectRelics(getRoot(c), getRoot(j));
				if(r == -1) continue;
				int num = findRoot(getRoot(r), getRoot(c));
				num = findRoot(getRoot(r), getRoot(j));
				if(num > target) return getRoot(r);
			}
			continue;
		}
		int num = findRoot(getRoot(r), getRoot(c));
		num = findRoot(getRoot(r), getRoot(a));
		if(num > target) return getRoot(r);
	}
 
	if(select[getRoot(c)] > target ) return getRoot(c);
    for(int i = 0; i< N; i++) {
        if(select[i] > target) return i;
    }
	return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 620 KB Correct : C = 59
2 Incorrect 1 ms 620 KB Wrong
3 Correct 1 ms 492 KB Correct : C = 2
4 Runtime error 3 ms 1004 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 3 ms 1260 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 1 ms 876 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Correct 1 ms 620 KB Correct : C = 58
8 Runtime error 1 ms 748 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Incorrect 1 ms 620 KB Wrong
10 Runtime error 2 ms 1004 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Correct 1 ms 524 KB Correct : C = 115
12 Correct 1 ms 620 KB Correct : C = 170
13 Correct 1 ms 620 KB Correct : C = 187
14 Runtime error 2 ms 1004 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 2 ms 876 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 2 ms 876 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 4 ms 1004 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Correct 1 ms 620 KB Correct : C = 168
19 Correct 1 ms 620 KB Correct : C = 99
20 Incorrect 1 ms 620 KB Wrong
21 Correct 1 ms 620 KB Correct : C = 100
22 Correct 1 ms 620 KB Correct : C = 111
23 Correct 1 ms 620 KB Correct : C = 60
24 Correct 1 ms 620 KB Correct : C = 102
25 Correct 1 ms 620 KB Correct : C = 98
26 Incorrect 1 ms 620 KB Wrong
27 Runtime error 2 ms 1004 KB Execution killed with signal 11 (could be triggered by violating memory limits)