Submission #320833

# Submission time Handle Problem Language Result Execution time Memory
320833 2020-11-10T04:54:36 Z seedkin Lokahian Relics (FXCUP4_lokahia) C++17
0 / 100
2 ms 1004 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 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++) {
			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 < 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(root[j] != -1) 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;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 640 KB Wrong
2 Incorrect 1 ms 620 KB Wrong
3 Correct 1 ms 620 KB Correct : C = 178
4 Runtime error 1 ms 748 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Incorrect 1 ms 620 KB Wrong
6 Correct 1 ms 620 KB Correct : C = 298
7 Runtime error 1 ms 876 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Correct 1 ms 620 KB Correct : C = 171
9 Incorrect 1 ms 620 KB Wrong
10 Correct 1 ms 620 KB Correct : C = 100
11 Incorrect 1 ms 620 KB Wrong
12 Correct 1 ms 640 KB Correct : C = 60
13 Correct 1 ms 492 KB Correct : C = 2
14 Runtime error 2 ms 1004 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Correct 2 ms 620 KB Correct : C = 278
16 Incorrect 1 ms 620 KB Wrong
17 Correct 1 ms 620 KB Correct : C = 169
18 Correct 1 ms 620 KB Correct : C = 103
19 Correct 1 ms 620 KB Correct : C = 276
20 Runtime error 2 ms 1004 KB Execution killed with signal 11 (could be triggered by violating memory limits)
21 Incorrect 1 ms 620 KB Wrong
22 Incorrect 1 ms 620 KB Wrong
23 Runtime error 2 ms 876 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Runtime error 2 ms 1004 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Incorrect 1 ms 620 KB Wrong
26 Correct 1 ms 620 KB Correct : C = 99
27 Correct 1 ms 620 KB Correct : C = 59