//Let's join Kaede Takagaki Fan Club !! #include #include #include using namespace std; typedef long long ll; typedef pair P; typedef pair P1; typedef pair P2; #define pu push #define pb push_back #define mp make_pair #define eps 1e-7 #define INF 1000000000 #define fi first #define sc second #define rep(i,x) for(int i=0;i void dmp(T a){ rep(i,a.size()) cout << a[i] << " "; cout << endl; } template bool chmax(T&a, T b){ if(a < b){ a = b; return 1; } return 0; } template bool chmin(T&a, T b){ if(a > b){ a = b; return 1; } return 0; } template void g(T &a){ cin >> a; } template void o(const T &a,bool space=false){ cout << a << (space?' ':'\n'); } //ios::sync_with_stdio(false); const int mod = 1000000007; template void add(T&a,T b){ a+=b; if(a >= mod) a-=mod; } #define SZ 100005 int n, k, q; int mx[100005]; P ar[SZ*2]={}; int pos[SZ]={},id=0,up[SZ],dep[SZ]; P mn[20][SZ*2]={}; int sz[SZ*2]={}; vectoredge[SZ]; struct LCA{ //SZは元の木の頂点数より大 //外部でedge[]に隣接状況を持って置く必要あり void dfs(int v,int u,int d){ pos[v] = id; up[v] = u; dep[v] = d; ar[id++] = mp(d,v); for(int i=0;i= id) mn[j+1][i] = mn[j][i]; else mn[j+1][i] = min(mn[j][i], mn[j][i+(1<0){ k=(k-1)/2; seg[k]=kaede.get(seg[k*2+1],seg[k*2+2]); } } int query(int a,int b,int k,int l,int r){ if(r