# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
856161 | gortomi | Floppy (RMI20_floppy) | C++17 | 71 ms | 13740 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 <stdlib.h>
#include <string.h>
#include "floppy.h"
#include <bits/stdc++.h>
using namespace std;
void read_array(int subtask_id, const vector<int> &v) {
stack<int> s;
int n = v.size();
s.push(1e9 + 1);
string bits = "";
for(auto x : v)
{
while(s.top() < x)
{
s.pop();
bits += '1';
}
bits += '0';
s.push(x);
}
save_to_floppy(bits);
}
vector<int> solve_queries(int subtask_id, int N,
const string &bits,
const vector<int> &a, const vector<int> &b) {
int m = a.size();
vector<int> ans(m);
vector<vector<pair<int, int> > > query(N);
for(int i = 0; i < m; i++)
{
query[b[i]].push_back({a[i], i});
}
vector<int> c;
int k = 0;
for(int i = 0; i < N; i++)
{
while(bits[k] != '0')
{
c.pop_back();
k++;
}
k++;
c.push_back(i);
for(auto [l, ind] : query[i])
{
ans[ind] = *lower_bound(c.begin(), c.end(), l);
}
}
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... |