#include "floppy.h"
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;}
template <typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;}
ll readint(){
ll x=0,f=1; char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int go[100005][20];
void read_array(int subtask_id, const std::vector<int> &v){
int n=(int)v.size();
string ret="";
vector<int> stk;
for(int i=0;i<n;i++){
while(!stk.empty()&&v[stk.back()]<v[i]){
stk.pop_back();
ret+='0';
}
ret+='1';
stk.push_back(i);
}
save_to_floppy(ret);
}
vector<int> solve_queries(int subtask_id, int n,
const std::string &bits,
const std::vector<int> &a, const std::vector<int> &b){
int q=a.size();
vector<int> stk;
int ptr=0;
for(int i=0;i<n;i++){
while(bits[ptr]=='0') stk.pop_back(),ptr++;
go[i][0]=(stk.empty()?-1:stk.back());
stk.push_back(i);
ptr++;
}
for(int j=1;j<20;j++){
for(int i=0;i<n;i++){
go[i][j]=(go[i][j-1]==-1?-1:go[go[i][j-1]][j-1]);
}
}
vector<int> res;
for(int i=0;i<q;i++){
int x=b[i];
for(int j=19;j>=0;j--){
if(go[x][j]>=a[i]){
x=go[x][j];
}
}
res.pb(x);
}
return res;
}
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 |
1 ms |
820 KB |
Output is correct |
2 |
Correct |
1 ms |
824 KB |
Output is correct |
3 |
Correct |
1 ms |
832 KB |
Output is correct |
4 |
Correct |
1 ms |
824 KB |
Output is correct |
5 |
Correct |
1 ms |
832 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
5516 KB |
Output is correct |
2 |
Correct |
17 ms |
5564 KB |
Output is correct |
3 |
Correct |
20 ms |
5560 KB |
Output is correct |
4 |
Correct |
25 ms |
5720 KB |
Output is correct |
5 |
Correct |
20 ms |
5568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
67 ms |
16052 KB |
Output is correct |
2 |
Correct |
67 ms |
15836 KB |
Output is correct |
3 |
Correct |
73 ms |
16144 KB |
Output is correct |
4 |
Correct |
69 ms |
16020 KB |
Output is correct |
5 |
Correct |
66 ms |
16076 KB |
Output is correct |