码迷,mamicode.com
首页 > 其他好文 > 详细

temp

时间:2017-10-12 21:38:56      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:技术   ora   splay   cst   stream   fine   ace   include   ror   

技术分享
 1 #include<iostream>
 2 #include<cstring>
 3 #include<cstdio>
 4 #include<cstdlib>
 5 #include<cmath>
 6 #include<algorithm>
 7 #define mod 98754321
 8 using namespace std;
 9 struct data {
10     int s[2];
11     int fa,id,size;
12     int v,val;
13 }t[150005];
14 int p[150005];
15 void pushup(int x) {
16     int lc=t[x].s[0],rc=t[x].s[1];
17     t[x].size=t[lc].size+t[rc].size+1;
18     t[x].v=t[lc].v+(long long)t[x].val*p[t[lc].size]%mod+(long long)p[t[rc].size+1]*t[rc].v%mod;
19     t[x].v%=mod;
20 }
21 void rorate(int x,int &k) {
22     int y=t[x].fa,z=t[y].fa,l,r;
23     if(t[y].s[0]==x) l=0;else l=1;
24     r=l^1;
25     if(y==k) k=x;
26     else{if(t[z].s[0]==y) t[z].s[0]=x;else t[z].s[1]=x;}
27     t[x].fa=z;t[y].fa=x;t[y].s[l]=t[x].s[r];t[t[x].s[r]].fa=y;
28     t[x].s[r]=y;
29     pushup(y);pushup(x);
30 }
31 int main() {
32     p[0]=1;for(int i=1;i<=150004;i++)p[i]=p[i-1]*27%mod;
View Code

 

temp

标签:技术   ora   splay   cst   stream   fine   ace   include   ror   

原文地址:http://www.cnblogs.com/wls001/p/7657894.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!