# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
821777 | LucaLucaM | Floppy (RMI20_floppy) | C++17 | 65 ms | 8204 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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";
}
while (!st.empty()) {
bits += "0";
st.pop();
}
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 < (int) a.size(); q++) {
int st = a[q] + 1, dr = b[q] + 1;
int p = dr;
while (l[p] >= st)
p = l[p];
answer.push_back(p - 1);
}
return answer;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |