#include "lokahia.h"
#include <vector>
#include <queue>
using namespace std;
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];
return true;
}
int FindBase(int N){ int n=N;
for(int i=0; i<n; i++) q.push_back(i), h[i]=i, sz[i]=1;
for(int i=0; !q.empty(); i++) {
nq.clear();
for(int i=0; i<10; 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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
512 KB |
Correct : C = 5 |
2 |
Correct |
6 ms |
512 KB |
Correct : C = 5 |
3 |
Correct |
6 ms |
640 KB |
Correct : C = 5 |
4 |
Correct |
6 ms |
640 KB |
Correct : C = 5 |
5 |
Incorrect |
6 ms |
640 KB |
Wrong |
6 |
Correct |
6 ms |
640 KB |
Correct : C = 5 |
7 |
Incorrect |
6 ms |
512 KB |
Wrong |
8 |
Correct |
5 ms |
512 KB |
Correct : C = 5 |
9 |
Incorrect |
7 ms |
640 KB |
Wrong |
10 |
Incorrect |
6 ms |
512 KB |
Wrong |
11 |
Incorrect |
6 ms |
512 KB |
Wrong |
12 |
Incorrect |
6 ms |
640 KB |
Wrong |
13 |
Incorrect |
6 ms |
640 KB |
Wrong |
14 |
Incorrect |
6 ms |
640 KB |
Wrong |
15 |
Correct |
6 ms |
640 KB |
Correct : C = 5 |
16 |
Incorrect |
6 ms |
512 KB |
Wrong |
17 |
Incorrect |
6 ms |
512 KB |
Wrong |
18 |
Incorrect |
6 ms |
512 KB |
Wrong |
19 |
Incorrect |
6 ms |
512 KB |
Wrong |
20 |
Incorrect |
6 ms |
512 KB |
Wrong |
21 |
Execution timed out |
3077 ms |
262144 KB |
Time limit exceeded |
22 |
Incorrect |
6 ms |
640 KB |
Wrong |
23 |
Incorrect |
6 ms |
512 KB |
Wrong |
24 |
Incorrect |
6 ms |
512 KB |
Wrong |
25 |
Incorrect |
7 ms |
640 KB |
Wrong |
26 |
Runtime error |
6 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
27 |
Incorrect |
5 ms |
512 KB |
Wrong |