Submission #926720

# Submission time Handle Problem Language Result Execution time Memory
926720 2024-02-13T14:34:01 Z hotboy2703 Floppy (RMI20_floppy) C++14
Compilation error
0 ms 0 KB
#include "floppy.h"
#include<bits/stdc++.h>
using namespace std;
const int MAXK = 16;
int sp[MAXK][40100];
string ansss;
vector <int> a;
int best(int x,int y){
    if (a[x] > a[y])return x;
    return y;
}
int lg[40100];
int id=0;
void solve(int l,int r,int node = id++){
    if (l > r)return;
    int sz = lg[r-l+1];
    int mid = best(sp[sz][l],sp[sz][r-(1<<sz)+1]);
    ansss[node<<1] = ansss[node<<1|1] = '0';
    if (mid > l){
        solve(l,mid-1);
        ansss[node<<1] = '1';
    }
    if (mid < r){
        ansss[node<<1|1] = '1';
        solve(mid+1,r);
    }
}


int n;
void read_array(int subtask, const vector<int> &v) {
    n = v.size();
    lg[1] = 0;
    for (int i = 2;i <= n;i ++)lg[i] = lg[i/2] + 1;
    a = v;
    for (int i = 0;i < n;i ++){
        sp[0][i] = i;
    }
    for (int j = 1;j < MAXK;j ++){
        for (int i = 0;i + (1<<j) - 1 < n;i++){
            sp[j][i] = best(sp[j-1][i],sp[j-1][i+(1<<(j-1))]);
        }
    }
    ansss.resize(2*n);
    solve(0,n-1);
    save_to_floppy(ansss);
}
string mom;
int cur = 0;
int depth[40100];
int sex[40100];
void decode(int node = id++){
    if (mom[node<<1] == '1'){
        decode();
    }
    sex[cur++] = node;
    if (mom[node<<1|1] == '1'){
        decode();
    }
}
int best2(int x,int y){
    if (sex[x] < sex[y])return x;
    return y;
}
vector<int> solve_queries(int subtask, int n, const string &data, const vector<pair<int, int>> &queries) {
    vector<int> anssswer(queries.size());
    lg[1] = 0;
    for (int i = 2;i <= n;i ++){
        lg[i] = lg[i>>1] + 1;
    }
    mom = data;
    id = 0;
    cur = 0;
    decode();
    for (int i = 0;i < n;i ++){
        sp[0][i] = i;
    }
    for (int j = 1;j < MAXK;j ++){
        for (int i = 0;i + (1<<j) - 1 < n;i ++){
            sp[j][i] = best2(sp[j-1][i],sp[j-1][i + (1<<(j-1))]);
        }
    }
    for (int i = 0;i < queries.size();i++){
        int l = queries[i].first;
        int r = queries[i].second;
        int sz = lg[r - l + 1];
        anssswer[i] = best2(sp[sz][l],sp[sz][r - (1<<sz) + 1]);
    }
    return anssswer;
}

Compilation message

floppy.cpp: In function 'std::vector<int> solve_queries(int, int, const string&, const std::vector<std::pair<int, int> >&)':
floppy.cpp:83:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |     for (int i = 0;i < queries.size();i++){
      |                    ~~^~~~~~~~~~~~~~~~
stub.cpp: In function 'void run2()':
stub.cpp:101:30: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  101 |     if (query_answers.size() != M) {
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~
/usr/bin/ld: /tmp/ccPFXTJO.o: in function `run2()':
stub.cpp:(.text+0x698): undefined reference to `solve_queries(int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&)'
collect2: error: ld returned 1 exit status