Submission #867601

# Submission time Handle Problem Language Result Execution time Memory
867601 2023-10-28T21:59:36 Z bibinm popa (BOI18_popa) C++17
Compilation error
0 ms 0 KB
#include "popa.h"
#include <vector>

using namespace std;

bool is_anc(long long x, long long y){
    // gcd(S_x, S_x) == gcd(S_x, S_{x+1}) => S_x | S_{x+1} => x+1 is an ancestor
    return query(x, x, x, y);
}

long long solve(long long n, long long* left, long long* right){
    for(long long i = 0; i < n; i += 1) left[i] = right[i] = -1;

    vector<long long> down_right;
    down_right.push_back(0);

    long long cur = 1;
    while(cur < n){
        while(cur < n and !is_anc(down_right.back(), cur)){
            down_right.push_back(cur);
            cur += 1;
        }

        if(cur == n) break;

        long long more_down = down_right.back(); down_right.pop_back();
        while(down_right.size() > 0 and is_anc(down_right.back(), cur)){
            right[down_right.back()] = more_down;
            more_down = down_right.back(); down_right.pop_back();
        }

        left[cur] = more_down;

        down_right.push_back(cur);

        cur += 1;
    }


    long long more_down = down_right.back(); down_right.pop_back();
    while(down_right.size() > 0){
        right[down_right.back()] = more_down;
        more_down = down_right.back(); down_right.pop_back();
    }

    return more_down;
}

Compilation message

/usr/bin/ld: /tmp/ccqROYGD.o: in function `main':
grader.cpp:(.text.startup+0xf1): undefined reference to `solve(int, int*, int*)'
collect2: error: ld returned 1 exit status