题目如同洛谷普通平衡树。
数据加强,
题解rank1是 WBLT 写的,本来想学一下,但是我这个 SBT 跑的还是蛮快的,就不学了。
目前洛谷rank3,可是rank1,rank2都是SBT 写的。。为啥比我的要快。。
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<vector>
#define ll long long
#define llu unsigned ll
using namespace std;
char buffer[100001], * S, * T;
inline char Get_Char()
{
if (S == T)
{
T = (S = buffer) + fread(buffer, 1, 100001, stdin);
if (S == T) return EOF;
}
return *S++;
}
inline int read()
{
char c;int re = 0;
for (c = Get_Char();c < '0' || c>'9';c = Get_Char());
while (c >= '0' && c <= '9') re = re * 10 + (c - '0'), c = Get_Char();
return re;
}
const double alpha = 0.75;
const int maxn = 1100100;
const int inf = 0x7fffffff;
struct node
{
int val;
int lc, rc;
int si;
}t[maxn];
int tot, root;
void pushup(int p)
{
t[p].si = t[t[p].lc].si + t[t[p].rc].si + 1;
}
int newnode(int x)
{
int p = ++tot;
t[p