# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
650013 | taulant | Floppy (RMI20_floppy) | C++14 | 82 ms | 15508 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;
array<int, 2> t[16][42069];
int mx(int l, int r){
int y = 0, k = 1;
while(k+k <= r-l) ++y, k *= 2;
return max(t[y][l], t[y][r-k])[1];
}
void read_array(int _, const vector<int> &v){
stack<int> s;
string b;
for(int i : v){
while(s.size() && s.top() < i){s.pop(); b += '0';}
s.push(i); b += '1';
}
save_to_floppy(b);
}
vector<int> solve_queries(int _, int n, const string &b, const vector<int> &l, const vector<int> &r){
vector<int> v, ans;
int x = 69420;
for(char c : b){
if(c > 48) v.push_back(--x);
else ++x;
}
for(int i = 0; i < n; ++i) t[0][i] = {v[i], i};
for(int y = 0; y < 15; ++y){
int p = 1 << y;
for(int i = 0; i+p+p <= n; ++i) t[y+1][i] = max(t[y][i], t[y][i+p]);
}
for(int i = 0; i < l.size(); ++i) ans.push_back(mx(l[i], r[i]+1));
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... |