Submission #821774

# Submission time Handle Problem Language Result Execution time Memory
821774 2023-08-11T16:12:31 Z LucaLucaM Floppy (RMI20_floppy) C++17
0 / 100
61 ms 9012 KB
#include <bits/stdc++.h>
#include "floppy.h"

using namespace std;

void read_array(int subtask_id, const std::vector<int> &v) {
    int n = (int) v.size();
    stack<int>st;
    string bits = "";
    for (int i = 0; i < n; i++) {
        while (!st.empty() && v[i] >= v[st.top()]) {
            st.pop();
            bits += "0";
        }
        st.push(i);
        bits += "1";
    }

    save_to_floppy(bits);
}

std::vector<int> solve_queries(int subtask_id, int N,
        const std::string &bits,
        const std::vector<int> &a, const std::vector<int> &b) {
    vector<int>answer;
    int n = (int) bits.size();
    n >>= 1;
    vector<int>l(n + 1);

    int sz = 0;

    for (int i = 0, j = 0; i < (int) bits.size(); i++) {
        if (bits[i] == '0') {
            sz--;
        } else {
            l[++j] = sz;
            sz++;
        }
    }

    for (int q = 0; q < N; q++) {
        int st = a[q] + 1, dr = b[q] + 1;
        int p = dr;
        while (l[p] >= st)
            p = l[p];
        answer[q] = p - 1;
    }

    return answer;
}

Compilation message

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) {
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 792 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 2720 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 61 ms 9012 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -