# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1056969 | kititnik | Floppy (RMI20_floppy) | C++14 | 0 ms | 0 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;
#define ll long long
void read_array(int sub, const vector<int> &v) {
string bits;
stack<int> st;
for(int i = 0; i < v.size(); i++)
{
while(!st.empty() && v[i] > v[st.top()])
{
st.pop();
bits += "0";
}
st.push(i);
bits += "1";
}
save_to_floppy(s);
}
vector<int> solve_queries(int sub, int n, const string &bits, const vector<int> &a, const vector<int> &b) {
vector<int> ans;
for(int q = 0; q < a.size(); q++)
{
deque<int> qu;
int zeros = 0;
for(int i = 0; i <= a[q]; i++)
{
if(bits[i] == '0') zeros++;
}
int start = a[q] + zeros;
int end = b[q]+zeros;
int p = start;
for(int i = start; i <= end; i++)
{
while(bits[p] == '0')
{
qu.pop_back();
p++;
}
qu.push_back(i-zeros);
p++;
}
ans.push_back(qu.front());
}
return ans;
}