#include #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define Yes cout << "Yes" << "\n" #define No cout << "No" << "\n" #define rtr0 return(0) #define all(x) x.begin(), x.end() using namespace std; //#include //using namespace atcoder; //using mint=static_modint<998244353>; //using mint=static_modint<1000000007>; ////using mint=modint; //#pragma GCC target("avx2") //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") using ll=long long; using l3=__int128; using ull=unsigned long long; using ld=long double; using P=pair; const ld PI=acos(-1); templatebool chmin(T&a,T b){if(a>b){a=b;return true;}return false;} templatebool chmax(T&a,T b){if(a dx={1,0,-1,0,1,-1,1,-1}; const vector dy={0,1,0,-1,1,1,-1,-1}; const int inf=1001001001; const ll INF=1001001001001001001; //ll mod=998244353; // LCA を求めるライブラリ struct LCA { vector> parent; // parent[d][v] := 2^d-th parent of v vector depth; LCA() { } LCA(const vector> &g, int r = 0) { init(g, r); } void init(const vector> &g, int r = 0) { int V = (int)g.size(); int h = 1; while ((1<(V, -1)); depth.assign(V, -1); dfs(g, r, -1, 0); for (int i = 0; i+1 < (int)parent.size(); ++i) for (int v = 0; v < V; ++v) if (parent[i][v] != -1) parent[i+1][v] = parent[i][parent[i][v]]; } void dfs(const vector> &g, int v, int p, int d) { parent[0][v] = p; depth[v] = d; for (auto e : g[v]) if (e != p) dfs(g, e, v, d+1); } int get(int u, int v) { if (depth[u] > depth[v]) swap(u, v); for (int i = 0; i < (int)parent.size(); ++i) if ( (depth[v] - depth[u]) & (1<= 0; --i) { if (parent[i][u] != parent[i][v]) { u = parent[i][u]; v = parent[i][v]; } } return parent[0][u]; } }; vector in,inr; vector sumA,sumB; ll cnt=0; void dfs(ll pos,ll bef,vector>&g){ in[pos]=cnt; inr[cnt]=pos; cnt++; for(auto[nxt,c]:g[pos]){ if(nxt==bef)continue; if(c==0){ sumA[nxt]=sumA[pos]+1; sumB[nxt]=sumB[pos]; } if(c==1){ sumA[nxt]=sumA[pos]; sumB[nxt]=sumB[pos]+1; } dfs(nxt,pos,g); } } //グラフは木 void solve(){ ll n,r,b;cin>>n>>r>>b; in.resize(n); inr.resize(n); sumA.resize(n); sumB.resize(n); vector> g(n); vector> gg(n); ld phi=(1+sqrt(5))/2; for(int i=2;i<=n;i++){ if(floor(i*phi)<=n){ g[i-1].push_back({floor(i*phi)-1,0}); gg[i-1].push_back(floor(i*phi)-1); } } for(int i=1;i<=n;i++){ if(floor(i*phi*phi)<=n){ g[i-1].push_back({floor(i*phi*phi)-1,1}); gg[i-1].push_back(floor(i*phi*phi)-1); } } dfs(0,-1,g); ll q;cin>>q; set st; vector f(n); LCA Z(gg); //for(auto x:in)cout<>t>>x; if(t==1){ x--; ll id=in[x]; //黒から白 if(!f[x]){ f[x]=true; if(st.size()==0){ st.insert(id); ca=0,cb=0; } else{ auto it=st.lower_bound(id); auto itr=it; if(it==st.end())itr=st.begin(); auto itl=it; if(it==st.begin())itl=st.end(); itl--; ll L=inr[*itl]; ll R=inr[*itr]; //cout<>t; rep(i,t)solve(); } //銅3赤6橙4黄3青1水4