机缘
初一在家玩电脑,偶然翻到了 优快云 这个网站。当时我喜欢在这里搜索一些关于 html 的内容,想要做出很牛的网站。
我也没想到这个网站能陪伴我这么久。
收获
首先是第一阶段(初一)。
这段时间我主要看一些大神对 flask 的讲解,自己还搭出了非常简陋的“服务器”,实际上就是在百度上爬取新闻罢了。
顺带写了一些博客,还帮助一些人解决了相关的问题。
第一次被赞、第一次发布回答、第一次回答被采纳……这些足够我高兴一整天。
第二阶段(初三)
初二下开始接触信息学竞赛,这是我人生的转折点。
到了初三,我会在这里问一些算法竞赛的问题,只不过不常来了。
日常
以前学习压力不大,经常在学习之余来这里放松,算是一种娱乐和消遣吧。
初三、高一时,我主要从事信息学竞赛。有的时候洛谷发了提问帖子,在这里同步发一下;有的时候洛谷不能投题解了,来这里发表题解;有的时候做几道其他 OJ 的好题,在这分享一下。可能曾经我引以为傲的内容,在现在看来不值一提;可能以前的兴奋,现在再也没有了。但是,优快云 见证了我的成长。
成就
写过最好的代码?那应该是这个纯手写的平衡树吧。
#include<cstdio>
using namespace std;
int min(int a,int b){return a>b?b:a;}
int abs(int a){return a<0?-a:a;}
int y,z,ck,t,rect,n,m,li,v,dui1[1500002],dui2[500001],siz1,siz2,op2=2000000000,op3=2000000000,ps[500002][2],tot,cnt[1000001],sz[1000001],ch[1000001][2],fa[1000001],val[1000001],rt;
char op[15];
void sw(int&x,int&y){rect=x,x=y,y=rect;}
void down(int*dui,int siz,int x){while(1){t=x;if(x<<1<=siz&&dui[x<<1]<dui[t])t=x<<1;if(x<<1<siz&&dui[x<<1|1]<dui[t])t=x<<1|1;if(t==x)return;sw(dui[x],dui[t]),x=t;}}
void up(int*dui,int x){while(x>>1&&dui[x]<dui[x>>1])sw(dui[x],dui[x>>1]),x>>=1;}
int top(){while(siz2&&dui1[1]==dui2[1])sw(dui1[siz1],dui1[1]),sw(dui2[siz2],dui2[1]),down(dui1,--siz1,1),down(dui2,--siz2,1);return dui1[1];}
void mt(int x){sz[x]=sz[ch[x][0]]+sz[ch[x][1]]+cnt[x];}
int g(int x){return x==ch[fa[x]][1];}
void r(int x){
y=fa[x],z=fa[y],ck=g(x),ch[y][ck]=ch[x][ck^1];
if(ch[x][ck^1])fa[ch[x][ck^1]]=y;
fa[y]=x,ch[x][ck^1]=y,fa[x]=z;
if(z)ch[z][y==ch[z][1]]=x;mt(y),mt(x);
}
void s(int x){for(int f=fa[x];f;r(x),f=fa[x])if(fa[f])r(g(x)==g(f)?f:x);rt=x;}
int pr(){
int cur=ch[rt][0];if(!cur)return 2000000000;
while(ch[cur][1])cur=ch[cur][1];return val[cur];
}
int nx(){
int cur=ch[rt][1];if(!cur)return 2000000000;
while(ch[cur][0])cur=ch[cur][0];return val[cur];
}
void in(int x){
if(!rt)rt=++tot,cnt[rt]=1,val[rt]=x,sz[rt]=1;
else{
int cur=rt,f=0;
while(1){
if(val[cur]==x){++cnt[cur],mt(cur),mt(f),s(cur),op3=0;break;}
f=cur,cur=ch[cur][x>val[f]];
if(!cur){val[++tot]=x,cnt[tot]=1,fa[tot]=f,ch[f][x>val[f]]=tot,mt(tot),mt(f),s(tot);break;}
}
}op3=min(op3,min(abs(pr()-x),abs(nx()-x)));
}
int main(){
scanf("%d%d%d",&n,&m,&ps[1][0]),ps[1][1]=ps[1][0],in(ps[1][0]);for(int i=2;i<=n;++i)scanf("%d",&ps[i][0]),in(ps[i][0]),dui1[++siz1]=abs(ps[i][0]-ps[i-1][0]),ps[i][1]=ps[i][0];
for(int i=siz1>>1;i;--i)down(dui1,siz1,i);op2=dui1[1];
while(m--){
op[4]=0,scanf("%s",op);
if(op[0]=='I'){scanf("%d%d",&li,&v),in(v);
if(li<n)dui2[++siz2]=abs(ps[li][1]-ps[li+1][0]),up(dui2,siz2),dui1[++siz1]=abs(v-ps[li+1][0]),up(dui1,siz1);
dui1[++siz1]=abs(ps[li][1]-v),up(dui1,siz1),op2=top(),ps[li][1]=v;}
if(op[4]=='G')printf("%d\n",op2);
if(op[4]=='S')printf("%d\n",op3);
}return 0;
}
/*
**Tips**
1. 您发布的文章将会展示至 [里程碑专区](https://blog.youkuaiyun.com/rank/list/milestone) ,您也可以在 [专区](https://blog.youkuaiyun.com/rank/list/milestone) 内查看其他创作者的纪念日文章
2. 优质的纪念文章将会获得神秘打赏哦
*/
憧憬
首先就是今年 NOIP 要拿一等奖,然后就回归正常文化课吧。毕竟高中了,时间紧。
希望能考上国防科技大学。