Submission #856245

# Submission time Handle Problem Language Result Execution time Memory
856245 2023-10-02T21:44:52 Z divad Floppy (RMI20_floppy) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "floppy.h"
using namespace std;
string bt;
const int NMAX = 4e5+2;
int bigr[NMAX], st[NMAX], vf;

void save_to_floppy(string &bits){
    bt = bits;
}

void read_array(int subtask_id, vector<int> &v){
    string bits = "";
    int n = v.size();
    vf = 0;
    for(int i = 0; i < n; i++){
        while(vf > 0 && st[vf] < v[i]){
            bits += "1";
            vf--;
        }
        st[++vf] = v[i];
        bits += "0";
    }
    save_to_floppy(bits);
}

vector<int> solve_queries(int subtask_id, int N, string &bits, vector<int> &a, vector<int> &b){
    int n = N, m = a.size();
    vf = 0;
    int pos = 0;
    for(int i = 1; i <= n; i++){
        while(bits[pos] == '1'){
            vf--;
            pos++;
        }
        bigr[i] = st[vf];
        st[++vf] = i;
        pos++;
    }
    vector<int> ans;
    for(int i = 0; i < a.size(); i++){
        int l = a[i], r = b[i];
        l++, r++;
        int id = r;
        while(bigr[id] >= l){
            id = bigr[id];
        }
        ans.push_back(id-1);
    }
    return ans;
}

Compilation message

floppy.cpp: In function 'std::vector<int> solve_queries(int, int, std::string&, std::vector<int>&, std::vector<int>&)':
floppy.cpp:41:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for(int i = 0; i < a.size(); i++){
      |                    ~~^~~~~~~~~~
floppy.cpp:28:16: warning: unused variable 'm' [-Wunused-variable]
   28 |     int n = N, m = a.size();
      |                ^
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/ccRT2sXK.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&)'
/usr/bin/ld: /tmp/ccRT2sXK.o: in function `run1()':
stub.cpp:(.text+0xb1d): undefined reference to `read_array(int, std::vector<int, std::allocator<int> > const&)'
collect2: error: ld returned 1 exit status