#include "lokahia.h"
#include <vector>
#include <queue>
using namespace std;
vector<int> v[300];
int h[300];
int sz[300];
typedef pair<int,int> pii;
vector<int> q,nq;
vector<pii> Q;
vector<pii> lft;
bool merge(int x, int y) {
int t;
if(h[x]==h[y]) t=h[x];
else t=CollectRelics(h[x],h[y]);
if(t<0) return false;
h[x]=t;
sz[x]+=sz[y];
for(int e : v[y]) v[x].push_back(e);
return true;
}
int FindBase(int N){ int n=N;
for(int i=0; i<n; i++) v[i].push_back(i), q.push_back(i), h[i]=i, sz[i]=1;
for(int i=0; i<10; i++) {
nq.clear();
for(int i=0; i<(int)q.size(); i+=2) {
if(i==(int)q.size()-1) {
lft.push_back({q[i], i});
}
if(merge(q[i], q[i+1])) {
nq.push_back(q[i]);
} else {
Q.push_back({q[i], q[i+1]});
}
}
q=nq;
}
if(lft.empty()) return -1;
int X=lft.back().first;
for(int i=0; i<(int)lft.size()-1; i++) merge(X, lft[i].first);
for(int i=0; i<(int)Q.size(); i++) merge(X, Q[i].first), merge(X, Q[i].second);
if(sz[X]>(n/2)) return h[X];
else return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
640 KB |
Correct : C = 151 |
2 |
Correct |
7 ms |
640 KB |
Correct : C = 105 |
3 |
Correct |
6 ms |
512 KB |
Correct : C = 4 |
4 |
Correct |
6 ms |
640 KB |
Correct : C = 230 |
5 |
Runtime error |
6 ms |
896 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Incorrect |
6 ms |
512 KB |
Wrong |
7 |
Correct |
6 ms |
640 KB |
Correct : C = 60 |
8 |
Correct |
5 ms |
640 KB |
Correct : C = 100 |
9 |
Correct |
7 ms |
640 KB |
Correct : C = 100 |
10 |
Correct |
6 ms |
512 KB |
Correct : C = 150 |
11 |
Correct |
6 ms |
640 KB |
Correct : C = 299 |
12 |
Correct |
7 ms |
640 KB |
Correct : C = 138 |
13 |
Correct |
5 ms |
512 KB |
Correct : C = 179 |
14 |
Correct |
7 ms |
640 KB |
Correct : C = 100 |
15 |
Correct |
5 ms |
512 KB |
Correct : C = 60 |
16 |
Correct |
6 ms |
640 KB |
Correct : C = 226 |
17 |
Correct |
6 ms |
640 KB |
Correct : C = 60 |
18 |
Correct |
7 ms |
640 KB |
Correct : C = 117 |
19 |
Correct |
6 ms |
640 KB |
Correct : C = 233 |
20 |
Correct |
7 ms |
640 KB |
Correct : C = 247 |
21 |
Incorrect |
6 ms |
640 KB |
Wrong |
22 |
Correct |
7 ms |
640 KB |
Correct : C = 251 |
23 |
Correct |
6 ms |
640 KB |
Correct : C = 144 |
24 |
Incorrect |
6 ms |
640 KB |
Wrong |
25 |
Correct |
7 ms |
640 KB |
Correct : C = 246 |
26 |
Correct |
6 ms |
640 KB |
Correct : C = 286 |
27 |
Incorrect |
6 ms |
640 KB |
Wrong |