#include <bits/stdc++.h>
using namespace std;
#include "lokahia.h"
int X[205];
int retval[205];
int FindBase(int N){
if (N==1) return 0;
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 = longest+1;
int ans = -2;
for (int x = fingroup+1; X[x]==fingroup&&x<N; x++){
ans = max(ans,retval[x]);
}
int queryCount = N-1;
while (cur!=-1){
if (X[cur]!=0 && X[X[cur]-1]==fingroup){
cur = X[cur]-1;
continue;
}
if (X[cur]==fingroup){
cur = X[cur]-1;
continue;
}
if (cur+1==fingroup){
cur = X[cur]-1;
continue;
}
if (compsize>N/2) return ans;
if (queryCount==300) return -1;
assert(cur!=fingroup&&cur>=0&&fingroup>=0&&cur<N&&fingroup<N);
int ret = CollectRelics(cur,fingroup);
queryCount++;
if (ret==-1){
cur = X[cur]-1;
continue;
}
else{
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) assert(ans!=-2);
return compsize>N/2?ans:-1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
620 KB |
Correct : C = 198 |
2 |
Correct |
1 ms |
620 KB |
Correct : C = 267 |
3 |
Correct |
1 ms |
620 KB |
Correct : C = 286 |
4 |
Correct |
1 ms |
620 KB |
Correct : C = 277 |
5 |
Correct |
1 ms |
620 KB |
Correct : C = 300 |
6 |
Correct |
1 ms |
620 KB |
Correct : C = 288 |
7 |
Correct |
1 ms |
620 KB |
Correct : C = 237 |
8 |
Incorrect |
1 ms |
620 KB |
Wrong |
9 |
Correct |
1 ms |
492 KB |
Correct : C = 4 |
10 |
Correct |
1 ms |
620 KB |
Correct : C = 171 |
11 |
Correct |
1 ms |
620 KB |
Correct : C = 118 |
12 |
Correct |
1 ms |
620 KB |
Correct : C = 248 |
13 |
Correct |
1 ms |
620 KB |
Correct : C = 300 |
14 |
Correct |
1 ms |
620 KB |
Correct : C = 235 |
15 |
Correct |
1 ms |
620 KB |
Correct : C = 288 |
16 |
Correct |
1 ms |
620 KB |
Correct : C = 300 |
17 |
Correct |
1 ms |
620 KB |
Correct : C = 199 |
18 |
Correct |
1 ms |
620 KB |
Correct : C = 172 |
19 |
Correct |
1 ms |
620 KB |
Correct : C = 119 |
20 |
Correct |
1 ms |
492 KB |
Correct : C = 0 |
21 |
Correct |
1 ms |
620 KB |
Correct : C = 247 |
22 |
Correct |
1 ms |
620 KB |
Correct : C = 292 |
23 |
Correct |
2 ms |
620 KB |
Correct : C = 300 |
24 |
Incorrect |
1 ms |
620 KB |
Wrong |
25 |
Correct |
1 ms |
620 KB |
Correct : C = 160 |
26 |
Correct |
1 ms |
620 KB |
Correct : C = 172 |
27 |
Correct |
1 ms |
620 KB |
Correct : C = 176 |