Submission #859960

# Submission time Handle Problem Language Result Execution time Memory
859960 2023-10-11T08:54:27 Z MateiKing80 Floppy (RMI20_floppy) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "floppy.h"
using namespace std;
int lift[20][400002];
int st[400002];
 
void read_array(int subtask_id, const vector<int> &v) {
    string bits = "";
    
    stack<int> stk;
    for(auto i : v)
    {
        while(stk.size() && stk.top() < i)
        {
            bits += "1";
            stk.pop();
        }
        stk.push(i) = i;
        bits += "0";
    }
    save_to_floppy(bits);
}
 
vector<int> solve_queries(int subtask_id, int N, const string &bits, const vector<int> &a, const vector<int> &b) 
{
    int n = N, m = a.size();
    int vf = 0;
    int pos = 0;
    for(int i = 1; i <= n; i++)
    {
        while(bits[pos] == '1')
        {
            vf--;
            pos++;
        }
        lift[0][i] = st[vf];
        st[++vf] = i;
        pos++;
    }
    for(int i = 1; i < 20; i++)
    {
        for(int j = 1; j <= n; j++)
            lift[i][j] = lift[i-1][lift[i-1][j]];
    }
    vector<int> ans;
    for(int i = 0; i < m; i++)
    {
        int l = a[i], r = b[i];
        l++, r++;
        int id = r;
        for(int j = LMAX-1; j >= 0; j--)
        {
            if(lift[j][id] >= l)
                id = lift[j][id];
        }
        ans.push_back(id-1);
    }
    return ans;
}

Compilation message

floppy.cpp: In function 'void read_array(int, const std::vector<int>&)':
floppy.cpp:18:17: error: invalid use of 'void'
   18 |         stk.push(i) = i;
      |         ~~~~~~~~^~~
floppy.cpp: In function 'std::vector<int> solve_queries(int, int, const string&, const std::vector<int>&, const std::vector<int>&)':
floppy.cpp:51:21: error: 'LMAX' was not declared in this scope; did you mean 'NL_NMAX'?
   51 |         for(int j = LMAX-1; j >= 0; j--)
      |                     ^~~~
      |                     NL_NMAX
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) {
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~