#include "lokahia.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
int p[205];
int sz[205];
int findSet(int u){
if(u == p[u]) return u;
else return findSet(p[u]);
}
int SZ(int u){ return sz[findSet(u)]; }
void unionSet(int u, int P){
u = findSet(u), P = findSet(P);
p[u] = P;
sz[P] += sz[u];
}
int FindBase(int N){
srand(time(NULL));
vector<int> v;
for(int i = 0;i < N;i++) v.push_back(i);
for(int i = 0;i < N;i++){
p[i] = i;
sz[i] = 1;
}
int cnt = 0;
while(cnt < 600){
int sz = v.size();
int i = rand() % (sz);
int j = rand() % (sz);
if(i > j) swap(i,j);
if(i == j) continue;
int a = v[i], b = v[j];
int x = CollectRelics(a, b);
cnt++;
if(x == -1) continue;
vector<int> nxt;
for(int k : v){
if(k != a && k != b) nxt.push_back(k);
}
if(x == a || x == b) nxt.push_back(x);
v = nxt;
nxt.clear();
if(a != x) unionSet(a,x);
if(b != x) unionSet(b,x);
if(SZ(x) > (N/2)){
//cout << x << "\n";
return x;
}
}
//assert(false);
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
7 ms |
640 KB |
Partially correct : C = 600 |
2 |
Correct |
5 ms |
640 KB |
Correct : C = 51 |
3 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 600 |
4 |
Correct |
5 ms |
640 KB |
Correct : C = 32 |
5 |
Correct |
5 ms |
512 KB |
Correct : C = 178 |
6 |
Partially correct |
5 ms |
512 KB |
Partially correct : C = 600 |
7 |
Correct |
5 ms |
640 KB |
Correct : C = 50 |
8 |
Partially correct |
5 ms |
512 KB |
Partially correct : C = 600 |
9 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 600 |
10 |
Correct |
5 ms |
640 KB |
Correct : C = 294 |
11 |
Correct |
5 ms |
640 KB |
Correct : C = 198 |
12 |
Partially correct |
5 ms |
640 KB |
Partially correct : C = 579 |
13 |
Partially correct |
5 ms |
640 KB |
Partially correct : C = 600 |
14 |
Correct |
5 ms |
512 KB |
Correct : C = 31 |
15 |
Partially correct |
5 ms |
640 KB |
Partially correct : C = 600 |
16 |
Partially correct |
5 ms |
768 KB |
Partially correct : C = 337 |
17 |
Correct |
5 ms |
640 KB |
Correct : C = 205 |
18 |
Partially correct |
5 ms |
512 KB |
Partially correct : C = 600 |
19 |
Correct |
5 ms |
512 KB |
Correct : C = 131 |
20 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 600 |
21 |
Incorrect |
5 ms |
512 KB |
Wrong |
22 |
Execution timed out |
1095 ms |
512 KB |
Time limit exceeded |
23 |
Correct |
5 ms |
512 KB |
Correct : C = 1 |
24 |
Partially correct |
5 ms |
640 KB |
Partially correct : C = 600 |
25 |
Partially correct |
5 ms |
512 KB |
Partially correct : C = 468 |
26 |
Incorrect |
5 ms |
640 KB |
Wrong |
27 |
Partially correct |
5 ms |
640 KB |
Partially correct : C = 600 |