首页 > 代码库 > splay

splay

#include<cstdio>#include<algorithm>#define inf 0x7fffffff#define N 100010using namespace std;inline int read(){    int x = 0,f = 1;char ch = getchar();    while (ch < ‘0‘ || ch > ‘9‘) {if (ch == ‘-‘)f = -1;ch = getchar();}    while (ch >= ‘0‘ && ch <= ‘9‘) {x = x * 10 + ch - ‘0‘; ch = getchar();}    return x * f;}struct Data{	int data,pos;}a[N];bool cmp1 (Data a,Data b){	if (a.data =http://www.mamicode.com/= b.data) return a.pos < b.pos;"%d ",x);	dfs (ch[x][1]);}int main(){	n = read();	for(int i = 2; i <= n + 1; i ++)	{		data[i] = read();		a[i].data = http://www.mamicode.com/data[i];"%d",size[ch[p][0]]);		reverse(i + 1, size[ch[p][0]] + 1);		if(i != n) printf(" ");	}	printf("\n");	return 0;}

  

splay