# 题解

('C'+'L'+'Y'+'A'+'K'+'I'+'O'+'I')

('G'+'L'+'Y'+'A'+'K'+'I'+'O'+'I')

('C'+'L'+'Y'+'A'+'K'+'I'+'O'+'I'+'N'+'O'+'I')

# 代码

#pragma GCC optimize("Ofast","inline")
#include <bits/stdc++.h>
#include "rts.h"
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=a;i<=b;i++)
#define Fod(i,b,a) for (int i=b;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define _SEED_ ('C'+'L'+'Y'+'A'+'K'+'I'+'O'+'I')
#define outval(x) printf(#x" = %d\n",x)
#define outvec(x) printf("vec "#x" = ");for (auto _v : x)printf("%d ",_v);puts("")
#define outtag(x) puts("----------"#x"----------")
#define outarr(a,L,R) printf(#a"[%d...%d] = ",L,R);\
For(_v2,L,R)printf("%d ",a[_v2]);puts("");
using namespace std;
typedef long long LL;
const int N=300005;
namespace so0{
int L=1,R=1,rv=0;
int vis[N];
vector <int> v;
void main(int n){
v.clear();
For(i,2,n)
v.pb(i);
random_shuffle(v.begin(),v.end());
while (!v.empty()){
int x=v.back();
v.pop_back();
if (vis[x])
continue;
if (y==rv){
while (R!=x)
}
else {
rv=L,L=y,vis[L]=1;
while (L!=x)
}
}
}
}
namespace so1{
int n;
int vis[N];
int father[N],hson[N];
int son[N][2],fa[N];
vector <int> v;
#define ls son[x][0]
#define rs son[x][1]
bool isroot(int x){
return son[fa[x]][0]!=x&&son[fa[x]][1]!=x;
}
int wson(int x){
return son[fa[x]][1]==x;
}
void rotate(int x){
int y=fa[x],z=fa[y],L=wson(x),R=L^1;
if (!isroot(y))
son[z][wson(y)]=x;
fa[x]=z,fa[y]=x,fa[son[x][R]]=y;
son[y][L]=son[x][R],son[x][R]=y;
}
void splay(int x){
for (int y=fa[x];!isroot(x);rotate(x),y=fa[x])
if (!isroot(y))
rotate(wson(x)==wson(y)?y:x);
}
void access(int x){
int t=0;
while (x){
splay(x);
hson[x]=t;
while (son[hson[x]][0])
hson[x]=son[hson[x]][0];
rs=t,t=x,x=fa[x];
}
}
void Ins(int a){
int x=1,y;
while (fa[x])
x=fa[x];
while (x!=a){
if (!vis[y])
break;
if (y==father[x])
x=ls;
else if (y==hson[x])
x=rs;
else {
while (!isroot(y))
y=fa[y];
x=y;
}
}
while (1){
fa[y]=father[y]=x;
vis[y]=1;
x=y;
if (x==a)
break;
}
access(x);
}
#undef ls
#undef rs
void main(int n){
so1::n=n;
v.clear();
vis[1]=1;
For(i,2,n)
v.pb(i);
random_shuffle(v.begin(),v.end());
clr(father),clr(hson);
while (!v.empty()){
int x=v.back();
v.pop_back();
if (!vis[x])
Ins(x);
}
}
}
void play(int n,int T,int type){
srand(_SEED_);
if (type==3)
so0::main(n);
else
so1::main(n);
}


posted @ 2019-03-15 20:07  -zhouzhendong-  阅读(...)  评论(...编辑  收藏