#include <bits/stdc++.h>
using namespace std;
#include "lokahia.h"
int FindBase(int N){
if (N == 1)
return 0;
srand(123);
int left = 400 - (N - 1);
vector<int> v(N, 1);
map<pair<int, int>, int> m;
int cnt = 0;
while (left) {
int hv = N;
int ta = rand() % hv;
for (int i = 0; i < N; i++) {
if (!v[i])
continue;
if (ta < v[i]) {
ta = i;
hv -= v[i];
break;
} else
ta -= v[i];
}
if (!hv)
break;
int tb = rand() % hv;
for (int i = 0; i < N; i++) {
if (!v[i] || i == ta)
continue;
if (tb < v[i]) {
tb = i;
hv -= v[i];
break;
} else
tb -= v[i];
}
if (ta > tb)
swap(ta, tb);
int tc;
if (m.count({ta, tb})) {
tc = m[{ta, tb}];
cnt++;
if (cnt == 10) {
cnt = 0;
left--;
}
} else {
m[{ta, tb}] = tc = CollectRelics(ta, tb);
left--;
cnt = 0;
}
if (tc != -1) {
if (tc != ta) {
v[tc] += v[ta];
v[ta] = 0;
}
if (tc != tb) {
v[tc] += v[tb];
v[tb] = 0;
}
}
}
int ans = -1, ma = -1;
for (int i = 0; i < N; i++)
if (v[i] >= ma) {
ma = v[i];
ans = i;
}
if (ans == -1)
return ans;
ma = 1;
for (int i = 0; i < N; i++)
if (i != ans)
ma += CollectRelics(i, ans) == ans;
if (ma > N / 2)
return ans;
return -1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 400 |
2 |
Correct |
6 ms |
640 KB |
Correct : C = 276 |
3 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 400 |
4 |
Partially correct |
7 ms |
640 KB |
Partially correct : C = 393 |
5 |
Incorrect |
7 ms |
640 KB |
Wrong |
6 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 357 |
7 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 400 |
8 |
Partially correct |
6 ms |
560 KB |
Partially correct : C = 390 |
9 |
Partially correct |
7 ms |
640 KB |
Partially correct : C = 400 |
10 |
Correct |
6 ms |
512 KB |
Correct : C = 0 |
11 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 400 |
12 |
Partially correct |
7 ms |
640 KB |
Partially correct : C = 400 |
13 |
Partially correct |
6 ms |
512 KB |
Partially correct : C = 391 |
14 |
Partially correct |
7 ms |
640 KB |
Partially correct : C = 400 |
15 |
Correct |
8 ms |
512 KB |
Correct : C = 213 |
16 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 334 |
17 |
Partially correct |
7 ms |
640 KB |
Partially correct : C = 400 |
18 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 400 |
19 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 400 |
20 |
Partially correct |
7 ms |
640 KB |
Partially correct : C = 400 |
21 |
Correct |
6 ms |
512 KB |
Correct : C = 210 |
22 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 400 |
23 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 348 |
24 |
Incorrect |
7 ms |
640 KB |
Wrong |
25 |
Partially correct |
7 ms |
640 KB |
Partially correct : C = 387 |
26 |
Correct |
6 ms |
512 KB |
Correct : C = 8 |
27 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 400 |