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];
void init(const vector<int>& v){
int n = v.size();
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]);
}
}
int mx(int l, int r){
int y = 0, le = 1;
while(le+le <= r-l) ++y, le *= 2;
return max(t[y][l], t[y][r-le])[1];
}
void read_array(int st, const vector<int> &v){
init(v);
string bits;
function<void(int, int)> dfs = [&](int l, int r){
int idx = mx(l, r);
bits += (idx > l)? "1" : "0";
bits += (idx < r-1)? "1" : "0";
if(idx > l) dfs(l, idx);
if(idx < r-1) dfs(idx+1, r);
};
dfs(0, v.size());
save_to_floppy(bits);
}
vector<int> solve_queries(int st, int n, const string &bits, const vector<int> &a, const vector<int> &b){
vector<int> v, ans;
int i = 0;
function<void(int)> dfs = [&](int d){
int l = (bits[i++] == '1'), r = (bits[i++] == '1');
if(l) dfs(d-1);
v.push_back(d);
if(r) dfs(d-1);
};
dfs(42069);
init(v);
for(int i = 0; i < a.size(); ++i) ans.push_back(mx(a[i], b[i]+1));
return ans;
}
Compilation message (stderr)
floppy.cpp: In function 'std::vector<int> solve_queries(int, int, const string&, const std::vector<int>&, const std::vector<int>&)':
floppy.cpp:47:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | for(int i = 0; i < a.size(); ++i) ans.push_back(mx(a[i], b[i]+1));
| ~~^~~~~~~~~~
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... |