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)
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |