刷题

今天上了一天的树,然后就下不来了,(根本就没上去吧)

打了道256行的SpalySplay,然后在COGS上过了道4星半的[NOI2005]维护数列,然后——我发现!@#在内网上竟然E了(喵喵喵?),然后,喵的COGS上是3s 256MB,其他OJ上全是1s 64MB= =

莫名尴尬= =

生活

颓了一天= =

刷SpalySplay板子刷到死= =,然后只能颓某黄学长的2048以示敬意= =

然后就颓成了这个鬼样子= =

不过SpalySplay真的难打= =,随手一打就是这个鬼样子= =

 #include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
inline int read(){
int sum(),f();
char ch(getchar());
for(;ch<''||ch>'';ch=getchar())
if(ch=='-')
f=-;
for(;ch>=''&&ch<='';sum=sum*+(ch^),ch=getchar());
return sum*f;
}
int ch[][],f[],key[],size[];
int sum[],maxl[],maxr[],maxn[];
int root,sz;
bool lazy[],rev[];
inline void clear(int x){
f[x]=ch[x][]=ch[x][]=size[x]=key[x]=sum[x]=;
lazy[x]=rev[x]=maxl[x]=maxr[x]=;
maxn[x]=-;
}
inline int get(int x){
return ch[f[x]][]==x;
}
inline int my_max(int a,int b){
return a>b?a:b;
}
inline void swp(int &a,int &b){
a^=b;
b^=a;
a^=b;
}
inline void update(int x){
int l(ch[x][]),r(ch[x][]);
sum[x]=sum[l]+sum[r]+key[x];
size[x]=size[l]+size[r]+;
maxn[x]=maxl[r]+key[x]+maxr[l];
if(l)
maxn[x]=my_max(maxn[x],maxn[l]);
if(r)
maxn[x]=my_max(maxn[x],maxn[r]);
maxl[x]=my_max(maxl[l],sum[l]+key[x]+maxl[r]);
maxr[x]=my_max(maxr[r],sum[r]+key[x]+maxr[l]);
}
inline void pushdown(int x){
int l(ch[x][]),r(ch[x][]);
if(lazy[x]){
rev[x]=lazy[x]=;
if(l){
lazy[l]=;
key[l]=key[x];
sum[l]=key[l]*size[l];
}
if(r){
lazy[r]=;
key[r]=key[x];
sum[r]=key[r]*size[r];
}
if(key[x]>=){
if(l)
maxl[l]=maxr[l]=maxn[l]=sum[l];
if(r)
maxl[r]=maxr[r]=maxn[r]=sum[r];
}
else{
if(l){
maxl[l]=maxr[l]=;
maxn[l]=key[l];
}
if(r){
maxl[r]=maxr[r]=;
maxn[r]=key[r];
}
}
}
if(rev[x]){
rev[x]=;
rev[l]^=;
rev[r]^=;
swp(maxl[l],maxr[l]);
swp(maxl[r],maxr[r]);
swp(ch[l][],ch[l][]);
swp(ch[r][],ch[r][]);
}
}
inline void rotate(int x){
int p(f[x]),g(f[p]),which(get(x));
pushdown(p);
pushdown(x);
ch[p][which]=ch[x][which^];
f[ch[p][which]]=p;
ch[x][which^]=p;
f[p]=x;
f[x]=g;
if(g)
ch[g][ch[g][]==p]=x;
update(p);
update(x);
}
inline void splay(int x,int y){
pushdown(x);
for(int fa=f[x];fa!=y;rotate(x),fa=f[x])
if(f[fa]!=y)
rotate(get(fa)==get(x)?fa:x);
if(!y)
root=x;
}
inline int find(int x){
int now(root);
while(){
pushdown(now);
if(x<=size[ch[now][]])
now=ch[now][];
else{
int tmp(size[ch[now][]]+);
if(x<=tmp)
return now;
x-=tmp;
now=ch[now][];
}
}
}
inline void build(int l,int r,int fa){
if(l>r)
return ;
if(l==r){
f[l]=fa;
size[l]=;
sum[l]=key[l];
if(key[l]>=)
maxl[l]=maxr[l]=maxn[l]=key[l];
else{
maxl[l]=maxr[l]=;
maxn[l]=key[l];
}
if(fa){
if(l<fa)
ch[fa][]=l;
else
ch[fa][]=l;
}
return;
}
int mid((l+r)>>);
build(l,mid-,mid);
build(mid+,r,mid);
f[mid]=fa;
update(mid);
if(fa){
if(mid<fa)
ch[fa][]=mid;
else
ch[fa][]=mid;
}
}
inline void erase(int x){
if(!x)
return;
erase(ch[x][]);
erase(ch[x][]);
clear(x);
}
char op[];
inline int gg(){
freopen("seq2005.in","r",stdin);
freopen("seq2005.out","w",stdout);
int n(read()),m(read());
key[++sz]=-;
for(int i=;i<=n;i++)
key[++sz]=read();
key[++sz]=-;
build(,n+,);
root=(n+)>>;
int all(n+);
while(m--){//cout<<'*'<<m<<endl;
scanf("%s",op);
if(op[]=='I'){
int pos(read()+),tot(read()),old(sz+);
int x(find(pos)),y(find(pos+));
splay(x,);
splay(y,x);
for(int i=;i<=tot;i++)
key[++sz]=read();
build(old,sz,);
int rt((old+sz)>>);
f[rt]=y;
ch[y][]=rt;
update(y);
update(x);
all+=tot;
continue;
}
if(op[]=='D'){
int pos(read()),tot(read());
int x(find(pos)),y(find(pos+tot+));
splay(x,);
splay(y,x);
erase(ch[y][]);
update(y);
update(x);
all-=tot;
continue;
}
if(op[]=='R'){
int pos(read()),tot(read());
int x(find(pos)),y(find(pos+tot+));
splay(x,);
splay(y,x);
int z(ch[y][]);
if(!lazy[z]){
rev[z]^=;
swp(ch[z][],ch[z][]);
swp(maxl[z],maxr[z]);
update(y);
update(x);
}
continue;
}
if(op[]=='G'){
int pos(read()),tot(read());
int x(find(pos)),y(find(pos+tot+));
splay(x,);
splay(y,x);
printf("%d\n",sum[ch[y][]]);
continue;
}
if(op[]=='K'){
int pos(read()),tot(read()),c(read());
int x(find(pos)),y(find(pos+tot+));
splay(x,);
splay(y,x);
int z(ch[y][]);
lazy[z]=;
key[z]=c;
sum[z]=size[z]*c;
if(c>=)
maxl[z]=maxr[z]=maxn[z]=sum[z];
else{
maxl[z]=maxr[z]=;
maxn[z]=c;
}
update(y);
update(x);
}
if(op[]=='X'){
int x(find()),y(find(all));
splay(x,);
splay(y,x);
printf("%d\n",maxn[ch[y][]]);
}
}
return ;
}
int K(gg());
int main(){;}

手累啊

Song

《Not Afraid》——Eminem

I'm not afraid

To take a stand

Everybody come take my hand

We'll walk to the route together

Through the storm

Whatever weather,cold or warm

Just lettin' you know that

You're not alone

Holla if you fell like you've been down on the same road

And I just cannot keep livin' in this way

So starting today

We'll break out of this cage

I'm standing up

I'ma face my demons

I'm manning up

I'ma hold my ground

I've had enough

Now I'm fed up

It's time to get my life back right now

I just cannot keep livin' in this way

暑假集训D10总结的更多相关文章

  1. 2015UESTC 暑假集训总结

    day1: 考微观经济学去了…… day2: 一开始就看了看一道题目最短的B题,拍了半小时交了上去wa了 感觉自己一定是自己想错了,于是去拍大家都过的A题,十分钟拍完交上去就A了 然后B题写了一发暴力 ...

  2. STL 入门 (17 暑假集训第一周)

    快速全排列的函数 头文件<algorithm> next_permutation(a,a+n) ---------------------------------------------- ...

  3. 暑假集训Day2 互不侵犯(状压dp)

    这又是个状压dp (大型自闭现场) 题目大意: 在N*N的棋盘里面放K个国王,使他们互不攻击,共有多少种摆放方案.国王能攻击到它上下左右,以及左上左下右上右下八个方向上附近的各一个格子,共8个格子. ...

  4. 暑假集训Day1 整数划分

    题目大意: 如何把一个正整数N(N长度<20)划分为M(M>=1)个部分,使这M个部分的乘积最大.N.M从键盘输入,输出最大值及一种划分方式. 输入格式: 第一行一个正整数T(T<= ...

  5. 2013ACM暑假集训总结-致将走上大三征途的我

    回想起这个暑假,从开始与雄鹰一起的纠结要不要进集训队,与吉吉博博组队参加地大邀请赛,害怕进不了集训队.当时激励我月份开始接触的,记得当时在弄运动会来着,然后就问了雄鹰一些输入输出的东西,怀着满心的期待 ...

  6. [补档]暑假集训D5总结

    %dalao 今天又有dalao来讲课,讲的是网络流 网络流--从入门到放弃:7-29dalao讲课笔记--https://hzoi-mafia.github.io/2017/07/29/27/   ...

  7. [补档]暑假集训D1总结

    归来 今天就这样回来了,虽然心里极其不想回来(暑假!@#的只有一天啊喂),但还是回来了,没办法,虽然不喜欢这个地方,但是机房却也是少数能给我安慰的地方,心再累,也没有办法了,不如好好集训= = %da ...

  8. 暑假集训(2)第七弹 -----今年暑假不AC(hdu2037)

    J - 今年暑假不AC Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:32768KB     64 ...

  9. 暑假集训D9总结

    考试 几乎绝望的考试= =,感觉自己啥都打不出来= =,就一道DP打了个贪心,剩下两道骗分,然而竟然排到前一半= =,不可思议= = 真是令人窒息的操作啊= = T1  [bzoj1592] Maki ...

随机推荐

  1. Cordova各个插件使用介绍系列(三)—$cordovaImagePicker从手机图库选择多张图片

    详情链接地址:http://www.ncloud.hk/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/cordova-3-cordovaimagepicker/ 这是能从手 ...

  2. JS获取浏览器类型和版本号

    JS获取浏览器类型和版本号,增加了IE11的判断. 2015/7/5更新: 简化代码逻辑 var zbrowser = {} var ua = navigator.userAgent.toLowerC ...

  3. Zookeeper:分布式程序的基石

    一.目录 1.zookeeper是什么? 2.安装.配置.启动.监控 3.javaApi基础用法 4.应用场景 5.CAP理论/paxos算法 二.zookeeper简介 官方版:zookeeper是 ...

  4. url地址栏拼接参数写法

    <script> function jiedan_do(elm){ var id=$(elm).attr("a"); window.location="__U ...

  5. django-xadmin列表页filter关联对象搜索问题

    环境:xadmin-for-python3 python3.5.2 django1.9.12 问题描述:Product ProductSku两个实体,ProductSku FK外键关联Product ...

  6. Vivo展柜灯怎样设计才吸引大量客户?

    1.vivo展柜灯计划的目标是使消耗者在无限的时空中最无效地承受信息.因而,vivo展柜灯计划便是围绕着怎样无效地进步展现活动的服从和质量停止的.除了展现环境本身的计划之外,展现对象陈列方式的计划也是 ...

  7. Vijos 1040 高精度乘法

    描述 高精度乘法 输入:两行,每行表示一个非负整数(不超过10000位) 输出:两数的乘积. 样例1 样例输入1 99 101 样例输出1 9999 题解 这道题和之前的Vijos 1010 清帝之惑 ...

  8. javascript精度问题与调整

    一个经典的问题: 0.1+0.2==0.3 答案是:false 因为:0.1+0.2=0.30000000000000004 第一次看到这个结果就是无比惊讶,下巴碰到地上,得深入了解下问题出在哪里,该 ...

  9. 使用hexdump工具追踪EXT4文件系统中的一个文件

    昨天追踪EXT4文件系统的过程中出了点问题,就是找不到文件,于是试了一下追踪FAT32文件系统的,成功之后有了点信心,今天继续嗑EXT4文件系统,终于找到啦,记录一下. 操作系统:linux(cent ...

  10. [基础架构]PeopleSoft Application Server 重要文件说明

    我们都知道PeopleSoft是由几个不同的服务组成的,他们在PeopleSoft体系结构中扮演着自己的角色.这些服务具有不同的文件结构并包含重要的可执行文件和配置文件. 以下是Peoplesoft体 ...