#include "lokahia.h"
#include<bits/stdc++.h>
using namespace std;
mt19937_64 rng(271);
int R(int a, int b)
{
return uniform_int_distribution<int>(a, b)(rng);
}
int FindBase(int N){
if(N==1) return 0;
vector<int> x;
for(int i=0; i<N; ++i) x.push_back(i);
shuffle(x.begin(), x.end(), rng);
vector<int> cnt(N);
for(int i=0; i<N/2; ++i)
{
int v1 = x[2*i];
int v2 = x[2*i+1];
int y = CollectRelics(v1, v2);
//printf("%d %d %d\n", v1, v2, y);
if(y != -1) cnt[y] ++;
}
if(N%2==1) cnt[x[N-1]]++;
int maxi = max_element(cnt.begin(), cnt.end()) - cnt.begin();
if(cnt[maxi] == 0) return -1;
int cc = 1;
for(int i=0; i<N; ++i)
if(i != maxi && -1 != CollectRelics(maxi, i))
++cc;
if(cc > N/2) return maxi;
return -1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
640 KB |
Correct : C = 299 |
2 |
Correct |
5 ms |
512 KB |
Correct : C = 60 |
3 |
Correct |
6 ms |
640 KB |
Correct : C = 297 |
4 |
Correct |
6 ms |
640 KB |
Correct : C = 179 |
5 |
Correct |
6 ms |
512 KB |
Correct : C = 177 |
6 |
Incorrect |
6 ms |
512 KB |
Wrong |
7 |
Correct |
6 ms |
512 KB |
Correct : C = 177 |
8 |
Correct |
6 ms |
640 KB |
Correct : C = 299 |
9 |
Correct |
6 ms |
640 KB |
Correct : C = 297 |
10 |
Correct |
6 ms |
512 KB |
Correct : C = 179 |
11 |
Correct |
6 ms |
384 KB |
Correct : C = 0 |
12 |
Correct |
7 ms |
640 KB |
Correct : C = 299 |
13 |
Correct |
6 ms |
640 KB |
Correct : C = 299 |
14 |
Correct |
6 ms |
512 KB |
Correct : C = 177 |
15 |
Correct |
5 ms |
512 KB |
Correct : C = 6 |
16 |
Correct |
6 ms |
640 KB |
Correct : C = 299 |
17 |
Correct |
5 ms |
512 KB |
Correct : C = 177 |
18 |
Correct |
7 ms |
640 KB |
Correct : C = 297 |
19 |
Correct |
6 ms |
640 KB |
Correct : C = 297 |
20 |
Correct |
6 ms |
640 KB |
Correct : C = 297 |
21 |
Correct |
6 ms |
640 KB |
Correct : C = 179 |
22 |
Correct |
6 ms |
512 KB |
Correct : C = 297 |
23 |
Correct |
6 ms |
640 KB |
Correct : C = 297 |
24 |
Correct |
6 ms |
640 KB |
Correct : C = 100 |
25 |
Correct |
6 ms |
640 KB |
Correct : C = 299 |
26 |
Correct |
6 ms |
512 KB |
Correct : C = 179 |
27 |
Correct |
7 ms |
640 KB |
Correct : C = 299 |