Submission #379218

# Submission time Handle Problem Language Result Execution time Memory
379218 2021-03-17T14:16:28 Z tqbfjotld Lokahian Relics (FXCUP4_lokahia) C++17
0 / 100
2 ms 748 KB
#include <bits/stdc++.h>
using namespace std;
#include "lokahia.h"

int X[205];
int retval[205];

int FindBase(int N){
    memset(X,-1,sizeof(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];
        }
        else{
            X[x+1] = X[x+1];
        }
    }
    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 = -1;
    for (int x = fingroup+1; X[x]==fingroup; x++){
        ans = max(ans,retval[x]);
    }
    int queryCount = N-1;
    while (cur!=-1){
        if (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 (queryCount==300) return -1;
        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;
        }

    }
	return compsize>N/2?ans:-1;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 620 KB Wrong
2 Incorrect 1 ms 620 KB Wrong
3 Incorrect 1 ms 620 KB Wrong
4 Correct 1 ms 620 KB Correct : C = 119
5 Correct 1 ms 620 KB Correct : C = 119
6 Correct 2 ms 620 KB Correct : C = 198
7 Incorrect 1 ms 620 KB Wrong
8 Incorrect 1 ms 620 KB Wrong
9 Incorrect 1 ms 620 KB Wrong
10 Correct 1 ms 620 KB Correct : C = 118
11 Correct 1 ms 492 KB Correct : C = 0
12 Incorrect 1 ms 620 KB Wrong
13 Correct 1 ms 620 KB Correct : C = 199
14 Correct 2 ms 620 KB Correct : C = 199
15 Incorrect 1 ms 620 KB Wrong
16 Incorrect 1 ms 620 KB Wrong
17 Incorrect 1 ms 620 KB Wrong
18 Incorrect 1 ms 620 KB Wrong
19 Incorrect 1 ms 620 KB Wrong
20 Incorrect 1 ms 620 KB Wrong
21 Incorrect 1 ms 748 KB Wrong
22 Incorrect 2 ms 620 KB Wrong
23 Correct 1 ms 620 KB Correct : C = 198
24 Correct 1 ms 492 KB Correct : C = 4
25 Incorrect 1 ms 620 KB Wrong
26 Incorrect 1 ms 620 KB Wrong
27 Correct 1 ms 620 KB Correct : C = 118