Submission #379240

# Submission time Handle Problem Language Result Execution time Memory
379240 2021-03-17T14:53:41 Z tqbfjotld Lokahian Relics (FXCUP4_lokahia) C++17
Compilation error
0 ms 0 KB
#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;
        }

    }
    for (auto x : stuff){
       if (x!=ans) assert(CollectRelics(x,ans)!=-1);
    }
	return compsize>N/2?ans:-1;
}

Compilation message

lokahia.cpp: In function 'int FindBase(int)':
lokahia.cpp:13:23: error: 'CollectRelics' was not declared in this scope
   13 |         retval[x+1] = CollectRelics(x,x+1);
      |                       ^~~~~~~~~~~~~
lokahia.cpp:45:19: error: 'CollectRelics' was not declared in this scope
   45 |         int ret = CollectRelics(cur,fingroup);
      |                   ^~~~~~~~~~~~~
In file included from /usr/include/c++/9/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:33,
                 from lokahia.cpp:1:
lokahia.cpp:63:27: error: 'CollectRelics' was not declared in this scope
   63 |        if (x!=ans) assert(CollectRelics(x,ans)!=-1);
      |                           ^~~~~~~~~~~~~