#include "lokahia.h"
int p[202];
int a[202];
int FindBase(int N){
int i, j, k, t;
for (i = 0; i < N; i++) {
p[i] = 1;
a[i] = i;
}
for (i = j = k = 0; i < N; i++) {
if (k) {
t = a[j] != a[i] ? CollectRelics(a[j], a[i]) : a[j];
if (t == -1) k--;
else {
p[i] = 0;
p[j]++;
a[j] = t;
k++;
}
}
else {
j = i;
k = 1;
}
}
if (!k) return -1;
for (i = 0; i < j; i++) if (p[i]) {
t = a[j] != a[i] ? CollectRelics(a[j], a[i]) : a[j];
if (t != -1) {
a[j] = t;
p[j] += p[i];
}
}
if (p[j] * 2 > N) return a[j];
return -1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
640 KB |
Correct : C = 292 |
2 |
Correct |
5 ms |
384 KB |
Correct : C = 4 |
3 |
Correct |
6 ms |
640 KB |
Correct : C = 198 |
4 |
Correct |
5 ms |
512 KB |
Correct : C = 172 |
5 |
Correct |
6 ms |
512 KB |
Correct : C = 170 |
6 |
Correct |
6 ms |
640 KB |
Correct : C = 209 |
7 |
Correct |
6 ms |
640 KB |
Correct : C = 216 |
8 |
Correct |
6 ms |
640 KB |
Correct : C = 198 |
9 |
Correct |
5 ms |
512 KB |
Correct : C = 176 |
10 |
Correct |
5 ms |
512 KB |
Correct : C = 122 |
11 |
Correct |
6 ms |
640 KB |
Correct : C = 197 |
12 |
Correct |
5 ms |
512 KB |
Correct : C = 60 |
13 |
Correct |
6 ms |
512 KB |
Correct : C = 0 |
14 |
Correct |
5 ms |
512 KB |
Correct : C = 128 |
15 |
Correct |
7 ms |
640 KB |
Correct : C = 289 |
16 |
Correct |
6 ms |
640 KB |
Correct : C = 100 |
17 |
Correct |
6 ms |
512 KB |
Correct : C = 118 |
18 |
Correct |
6 ms |
512 KB |
Correct : C = 150 |
19 |
Correct |
6 ms |
512 KB |
Correct : C = 197 |
20 |
Correct |
6 ms |
512 KB |
Correct : C = 111 |
21 |
Correct |
6 ms |
640 KB |
Correct : C = 293 |
22 |
Correct |
5 ms |
512 KB |
Correct : C = 297 |
23 |
Correct |
6 ms |
512 KB |
Correct : C = 117 |
24 |
Correct |
5 ms |
512 KB |
Correct : C = 177 |
25 |
Correct |
6 ms |
640 KB |
Correct : C = 189 |
26 |
Correct |
6 ms |
640 KB |
Correct : C = 293 |
27 |
Correct |
6 ms |
640 KB |
Correct : C = 290 |