#include <bits/stdc++.h>
using namespace std;
#include "lokahia.h"
int X[205];
int retval[205];
int FindBase(int N){
for (int x = 0; x<N; x++){
X[x] = x;
}
for (int x = 0; x<N-1; x++){
retval[x+1] = CollectRelics(x,x+1);
if (retval[x+1]!=-1){
X[x+1] = X[x];
}
}
int longest = -1;
int longpos = -1;
for (int x = 0; x<N; x++){
if (x-X[x]>longest){
longest = x-X[x];
longpos = x;
}
}
int fingroup = X[longpos];
int cur = N-1;
int compsize = 0;
int ans = -1;
for (int x = fingroup+1; X[x]==fingroup; x++){
ans = max(ans,retval[x]);
}
int queryCount = N-1;
vector<int> stuff;
while (cur!=-1){
if (compsize>N/2) return ans;
if (queryCount==300) return -1;
if (cur==fingroup){
compsize++;
stuff.push_back(cur);
if (X[cur]==0) cur = -1;
else cur = X[X[cur]-1]-1;
continue;
}
int ret = CollectRelics(cur,fingroup);
queryCount++;
if (ret==-1){
cur = X[cur]-1;
continue;
}
else{
for (int x = cur; X[x]==X[cur]&&x>=0; x--){
stuff.push_back(x);
}
compsize += cur-X[cur]+1;
ans = max(ans,ret);
if (X[cur]==0) cur = -1;
else cur = X[X[cur]-1]-1;
}
}
if (compsize>N/2)
for (auto x : stuff){
if (x!=ans) assert(CollectRelics(x,ans)!=-1);
}
return compsize>N/2?ans:-1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
620 KB |
Correct : C = 274 |
2 |
Correct |
1 ms |
620 KB |
Correct : C = 300 |
3 |
Correct |
1 ms |
620 KB |
Correct : C = 232 |
4 |
Correct |
1 ms |
620 KB |
Correct : C = 177 |
5 |
Correct |
1 ms |
620 KB |
Correct : C = 237 |
6 |
Partially correct |
2 ms |
620 KB |
Partially correct : C = 399 |
7 |
Partially correct |
2 ms |
620 KB |
Partially correct : C = 349 |
8 |
Correct |
1 ms |
492 KB |
Correct : C = 9 |
9 |
Partially correct |
1 ms |
620 KB |
Partially correct : C = 388 |
10 |
Correct |
2 ms |
620 KB |
Correct : C = 248 |
11 |
Correct |
2 ms |
620 KB |
Correct : C = 294 |
12 |
Correct |
2 ms |
768 KB |
Correct : C = 300 |
13 |
Correct |
2 ms |
620 KB |
Correct : C = 278 |
14 |
Correct |
2 ms |
620 KB |
Correct : C = 232 |
15 |
Correct |
2 ms |
620 KB |
Correct : C = 287 |
16 |
Correct |
1 ms |
620 KB |
Correct : C = 300 |
17 |
Correct |
1 ms |
620 KB |
Correct : C = 236 |
18 |
Correct |
1 ms |
492 KB |
Correct : C = 0 |
19 |
Correct |
1 ms |
620 KB |
Correct : C = 173 |
20 |
Partially correct |
2 ms |
620 KB |
Partially correct : C = 397 |
21 |
Incorrect |
1 ms |
620 KB |
Wrong |
22 |
Correct |
1 ms |
620 KB |
Correct : C = 161 |
23 |
Correct |
1 ms |
620 KB |
Correct : C = 239 |
24 |
Correct |
1 ms |
620 KB |
Correct : C = 300 |
25 |
Incorrect |
1 ms |
620 KB |
Wrong |
26 |
Partially correct |
2 ms |
620 KB |
Partially correct : C = 389 |
27 |
Correct |
1 ms |
620 KB |
Correct : C = 238 |