C++/*
* @Date: 2022-05-01 09:29:52
* @LastEditors: 1048576
* @FilePath: \code\CF\EDU292F.cpp
* @MajorAlgorithm:
*/
#include <bits/stdc++.h>
using namespace std;
template <class _Tp>
struct Stack
{
Stack() { v.clear(); }
vector<_Tp> v;
void operator+=(_Tp o) { v.push_back(o); }
_Tp operator--(int o)
{
int p = (*this)[-1];
v.pop_back();
return p;
}
_Tp operator[](int i) { return i > 0 ? v[i - 1] : v[v.size() + i]; }
bool empty() { return !(v.size()); }
};
template <class _FT, class _Tp>
struct Queue
{
struct _TTp
{
_Tp val, res;
};
Stack<_TTp> lft(), rht();
_FT func;
Queue(_FT func) : func(func) {}
void operator+=(_Tp val)
{
lft += {val, func(val, lft.empty() ? 0 : lft[-1].res)};
}
_Tp operator--(int o)
{
if (rht.empty())
while (!lft.empty())
rht += (lft--);
return rht--;
}
_Tp operator*()
{
int a, b;
a = lft.empty() ? 0 : lft[-1].res;
b = rht.empty() ? 0 : rht[-1].res;
return func(a, b);
}
};
signed main()
{
}