# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1056982 | kititnik | Floppy (RMI20_floppy) | C++14 | 454 ms | 10416 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"
#ifdef MINA
#include "grader.cpp"
#endif
using namespace std;
#define ll long long
void read_array(int sub, const vector<int> &v) {
int n = v.size();
stack<int> st;
string s;
for (int i = 0; i < n; i++) {
while (st.size() && v[i] > v[st.top()]) {
st.pop();
s.push_back('0');
}
st.push(i);
s.push_back('1');
}
save_to_floppy(s);
}
vector<int> solve_queries(int sub, int n, const string &bits, const vector<int> &a, const vector<int> &b) {
int q = a.size();
vector<array<int, 2>> ask[n];
vector<int> ans(q, -1);
for (int i = 0; i < q; i++) {
ask[b[i]].push_back({a[i], i});
}
// cout << "HI" << endl;
vector<int> st;
int cur = 0;
for (int i = 0; i < n; i++) {
while (bits[cur] == '0') {
st.pop_back();
cur++;
}
st.push_back(i);
// for (auto j : st) {
// cout << j << ' ';
// }
// cout << '\n';
cur++;
for (auto [l, idx] : ask[i]) {
for (int j = st.size() - 1; j >= 0; j--) {
if (j == 0 || st[j - 1] < l) {
ans[idx] = st[j];
break;
}
}
}
}
// for (auto i : ans) {
// cout << i << '\n';
// }
return ans;
}
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... |