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 "floppy.h"
#include <bits/stdc++.h>
using namespace std;
void read_array(int sid, const vector<int>& v){
string res = ""; int n = v.size();
vector<int> st;
for(int i = 0; i<n; ++i){
while(st.size() && v[i]>v[st.back()])
res += '0', st.pop_back();
st.push_back(i); res += '1';
} save_to_floppy(res);
}
vector<int> solve_queries(int sid, int n, const string& bits, const vector<int> &a, const vector<int> &b){
int m = a.size();
vector<vector<int>> huh(n);
for(int i = 0; i<m; ++i)
huh[b[i]].push_back(i);
vector<int> ans(m), st;
for(int i = 0, it = 0; i<n; ++i){
while(bits[it]=='0') st.pop_back(), ++it;
st.push_back(i); ++it;
for(auto x : huh[i])
ans[x] = *lower_bound(st.begin(), st.end(), a[x]);
} 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... |