This documentation is automatically generated by online-judge-tools/verification-helper
template<class T, class F>
class sliding_window {
vector<T> v;
deque<T> Q;
F f;
public:
int l, r;
explicit sliding_window(vector<T> &v, F f) : v(v), f(f), l(0), r(0) {};
void set(vector<T> &u){
v = u;
Q.clear();
l = 0; r = 0;
}
void reset(){
Q.clear();
l = 0, r = 0;
}
void slideL(){
if(Q.front() == l++) Q.pop_front();
}
void slideR(){
while(!Q.empty() && !f(v[Q.back()], v[r])) Q.pop_back();
Q.push_back(r++);
}
T get_index() {
if(l == r) return 0;
return Q.front();
}
T value() {
if(l == r) return 0;
return v[Q.front()];
}
};
#line 1 "datastructure/slidingwindow.cpp"
template<class T, class F>
class sliding_window {
vector<T> v;
deque<T> Q;
F f;
public:
int l, r;
explicit sliding_window(vector<T> &v, F f) : v(v), f(f), l(0), r(0) {};
void set(vector<T> &u){
v = u;
Q.clear();
l = 0; r = 0;
}
void reset(){
Q.clear();
l = 0, r = 0;
}
void slideL(){
if(Q.front() == l++) Q.pop_front();
}
void slideR(){
while(!Q.empty() && !f(v[Q.back()], v[r])) Q.pop_back();
Q.push_back(r++);
}
T get_index() {
if(l == r) return 0;
return Q.front();
}
T value() {
if(l == r) return 0;
return v[Q.front()];
}
};