#include <bits/stdc++.h>
#include "floppy.h"
using namespace std;
int lift[20][400002];
int st[400002];
void read_array(int subtask_id, const vector<int> &v) {
string bits = "";
stack<int> stk;
for(auto i : v)
{
while(stk.size() && stk.top() < i)
{
bits += "1";
stk.pop();
}
stk.push(i);
bits += "0";
}
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 n = N, m = a.size();
int vf = 0;
int pos = 0;
for(int i = 1; i <= n; i++)
{
while(bits[pos] == '1')
{
vf--;
pos++;
}
lift[0][i] = st[vf];
st[++vf] = i;
pos++;
}
for(int i = 1; i < 20; i++)
{
for(int j = 1; j <= n; j++)
lift[i][j] = lift[i-1][lift[i-1][j]];
}
vector<int> ans;
for(int i = 0; i < m; i++)
{
int l = a[i], r = b[i];
l++, r++;
int id = r;
for(int j = 19; j >= 0; j--)
{
if(lift[j][id] >= l)
id = lift[j][id];
}
ans.push_back(id-1);
}
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) {
| ~~~~~~~~~~~~~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
31544 KB |
Output is correct |
2 |
Correct |
4 ms |
31544 KB |
Output is correct |
3 |
Correct |
5 ms |
31552 KB |
Output is correct |
4 |
Correct |
4 ms |
31552 KB |
Output is correct |
5 |
Correct |
4 ms |
31552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
34240 KB |
Output is correct |
2 |
Correct |
20 ms |
34312 KB |
Output is correct |
3 |
Correct |
20 ms |
34216 KB |
Output is correct |
4 |
Correct |
20 ms |
34316 KB |
Output is correct |
5 |
Correct |
22 ms |
34232 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
75 ms |
42676 KB |
Output is correct |
2 |
Correct |
75 ms |
42424 KB |
Output is correct |
3 |
Correct |
79 ms |
42760 KB |
Output is correct |
4 |
Correct |
74 ms |
42404 KB |
Output is correct |
5 |
Correct |
82 ms |
42416 KB |
Output is correct |