int find(int x){ int now = rt,ans = 0; while (1){ if (x < w[now]){ now = son[now][0]; continue; } ans += size[son[now][0]]; if (x == w[now]){ splay(now); return ans + 1; } ans += num[now]; now = son[now][1]; } }