#include "floppy.h"
#include <bits/stdc++.h>
using namespace std;
void read_array(int subtask_id, const vector<int> &v) {
string bits = "";
int n=v.size();
stack<int> st;
for (int i=0; i<n; ++i){
while (st.size() && v[st.top()]<=v[i]) st.pop(), bits.push_back('0');
st.push(i);
bits.push_back('1');
}
save_to_floppy(bits);
}
vector<int> solve_queries(int subtask_id, int n, const string &bits,
const vector<int> &a, const vector<int> &b) {
vector<int> l(n);
stack<int> st;
vector<vector<pair<int, int>>> sparse(16, vector<pair<int, int>>(n));
int idx=0;
for (int i=0; i<n; ++i){
while (bits[idx]=='0') st.pop(), ++idx;
l[i]=st.size()?st.top():-1;
sparse[0][i]={l[i], -i};
st.push(i);
++idx;
}
for (int i=1; i<16; ++i) for (int j=0; j+(1<<i)<=n; ++j) sparse[i][j]=min(sparse[i-1][j], sparse[i-1][j+(1<<(i-1))]);
vector<int> ans;
auto get=[&](int l, int r) -> pair<int, int> {
int lg=__lg(r-l+1);
return min(sparse[lg][l], sparse[lg][r-(1<<lg)+1]);
};
for (int i=0; i<(int)a.size(); ++i){
ans.push_back(-get(a[i], b[i]).second);
}
return ans;
}
Compilation message
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) {
| ~~~~~~~~~~~~~~~~~~~~~^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
812 KB |
Output is correct |
2 |
Correct |
1 ms |
812 KB |
Output is correct |
3 |
Correct |
2 ms |
812 KB |
Output is correct |
4 |
Correct |
1 ms |
812 KB |
Output is correct |
5 |
Correct |
1 ms |
804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
3880 KB |
Output is correct |
2 |
Correct |
19 ms |
3736 KB |
Output is correct |
3 |
Correct |
15 ms |
3876 KB |
Output is correct |
4 |
Correct |
16 ms |
3752 KB |
Output is correct |
5 |
Correct |
16 ms |
3884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
63 ms |
13504 KB |
Output is correct |
2 |
Correct |
65 ms |
13468 KB |
Output is correct |
3 |
Correct |
60 ms |
13320 KB |
Output is correct |
4 |
Correct |
64 ms |
13592 KB |
Output is correct |
5 |
Correct |
63 ms |
13624 KB |
Output is correct |