#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){
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);
if(x == -1) continue;
vector<int> nxt;
for(int k : v){
if(k != a && k != b) nxt.push_back(k);
}
nxt.push_back(x);
v = nxt;
if(a != x) unionSet(a,x);
if(b != x) unionSet(b,x);
if(SZ(x) > (N/2)){
//cout << x << "\n";
return x;
}
}
return -1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
640 KB |
Wrong |
2 |
Correct |
5 ms |
640 KB |
Correct : C = 53 |
3 |
Correct |
5 ms |
512 KB |
Correct : C = 33 |
4 |
Incorrect |
5 ms |
768 KB |
Wrong |
5 |
Incorrect |
6 ms |
640 KB |
Wrong |
6 |
Incorrect |
5 ms |
512 KB |
Wrong |
7 |
Incorrect |
5 ms |
640 KB |
Wrong |
8 |
Incorrect |
5 ms |
512 KB |
Wrong |
9 |
Incorrect |
5 ms |
512 KB |
Wrong |
10 |
Incorrect |
5 ms |
640 KB |
Wrong |
11 |
Correct |
5 ms |
640 KB |
Correct : C = 33 |
12 |
Correct |
6 ms |
640 KB |
Correct : C = 52 |
13 |
Incorrect |
5 ms |
640 KB |
Wrong |
14 |
Incorrect |
6 ms |
640 KB |
Wrong |
15 |
Incorrect |
5 ms |
640 KB |
Wrong |
16 |
Incorrect |
5 ms |
512 KB |
Wrong |
17 |
Correct |
4 ms |
512 KB |
Correct : C = 2 |
18 |
Incorrect |
5 ms |
640 KB |
Wrong |
19 |
Incorrect |
6 ms |
640 KB |
Wrong |
20 |
Incorrect |
5 ms |
640 KB |
Wrong |
21 |
Incorrect |
5 ms |
640 KB |
Wrong |
22 |
Incorrect |
5 ms |
640 KB |
Wrong |
23 |
Incorrect |
6 ms |
512 KB |
Wrong |
24 |
Partially correct |
5 ms |
640 KB |
Partially correct : C = 406 |
25 |
Incorrect |
5 ms |
640 KB |
Wrong |
26 |
Execution timed out |
1094 ms |
512 KB |
Time limit exceeded |
27 |
Incorrect |
5 ms |
512 KB |
Wrong |