正文
增加 23 行删除 23 行
123456789101112135 行未改动192021222324252627282910 行未改动4041424344454647482 行未改动5152535455565758596061626364656667686970717273747521 行未改动97989910010110210310410535 行未改动1411421431441451461471481491501511521531541551561571581591601611621631641651661674 行未改动17217317417517617717817918018 行未改动1992002012022032042052062075 行未改动21321421521621721821922022122222322413 行未改动238239240241242243244245246247248249250251252253254255256257258259260介绍下本蒟蒻的丑死的码风$qwq$...(码风大概是魔改了神犇$Menci$的)~~在打CF时并不是这个码风~~### 码风概述:1. 所有的```#include```后必须有一个空格,例如```#include <iostream>```2. 无论什么样子的程序,都必须写```cstdio cstring algorithm iostream```这四个头文件。3. 在主程序的```int main()```中要加$void$,即为```int main(void)```4. **一般**不写```using namespace std;```5. 所有的变量必须定义在第一个自定义函数之前,且变量和第一个自定义函数,最后一个自定义函数和$main$之间必须有一个换行6. 每个函数之后尽可能有$return$,7. 在一般情况下,在花括号内的内容不加逗号5 行未改动### 空格:>个人感觉自己的空格比较的~~毒瘤~~。>>1.在每个函数声明时,函数名后的括号与函数名之间必须有一个空格,而且括号内如果需要声明变量,则要先有一个空格,且逗号的前后都必须有一个空格。>>2.在for循环的声明中,每一个字符(变量名除外),都要用空格隔开。>>3.数组内一般不加空格,但是如果有运算符则运算符前后必须有空格。>>4.每个可以前后匹配的括号前后必须有空格。10 行未改动qweqweqweqweqweqweqweqwe;if ( qweqweqweqweqwe ) {qewqweqweqweqweq;qweqweqweqweq;}else {qweqweqweqweq;qweqweqwrreeqwqqwe;qweqewqweqweqewq;2 行未改动}```### 变量:>1.基本所有变量都是全局变量,但有些ans,sum最后统计答案时使用的变量可以定义为局部变量。>2.所有的变量名称都必须与要存储的东西的中文意思有沾边,比如树直接定义为tree而不是T。(极度不能容忍变量名直接为a,b,c,d,e,f,g,的情况。>3.定义N,M等时一般只用N,M为名称而不是MAXN,MAXM.>4.定义的结构体类型在定义变量时必须紧接着声明完成结构体后,并且结构体中变量需要定义一个加一个换行。>5.在变量命名时较长的变量名可以用_来连接,并且大小写交替使用,如```Add_Tree_Val```---把上边所有毒瘤的码风结合起来之后代码大概长这个样子qwq..update:还是加上模板舒服qwq21 行未改动#define PI 3.141592653590#define rint register inttemplate < class T > inline void read ( T &x ) {T s = 0 , w = 1;char ch = getchar ();while ( ch > '9' || ch < '0' ) { if ( ch == '-' ) w = -1; ch = getchar ();}while ( ch >= '0' && ch <= '9' ) { s = s * 10 + ch - '0'; ch = getchar ();}x = s * w;return;}template < class T , typename ...Argc > inline void read ( T &x , Argc &...Args ) {read ( x );read ( Args... );return;}template < class T > inline T max ( T x , T y ) {return x > y ? x : y;}template < class T > inline T min ( T x , T y ) {return x < y ? x : y;}template < class T > inline void abs ( T x ) {return x > 0 ? x : -x;}inline int _read () {int s = 0 , w = 1;char ch = getchar ();while ( ch > '9' || ch < '0' ) { if ( ch == '-' ) w = -1; ch = getchar ();}while ( ch >= '0' && ch <= '9' ) { s = s * 10 + ch - '0'; ch = getchar ();}return s * w;}35 行未改动void Splay ( int x , int goal ) {while ( tree[x].father != goal ) {int y = tree[x].father;int z = tree[y].father;if ( z != goal )( tree[y].ch[0] == x ) ^ ( tree[z].ch[0] == y ) ? rotate ( x ) : rotate ( y );rotate ( x );}if ( goal == 0 )root = x;return;}void insert ( int x ) {int cur = root , father = 0;while ( cur && tree[cur].val != x ) {father = cur;cur = tree[cur].ch[x > tree[cur].val];}if ( cur )tree[cur].cnt++;else {cur = ++tot;if ( father )tree[father].ch[x > tree[father].val] = cur;tree[cur].ch[0] = tree[cur].ch[1] = 0;tree[cur].father = father;tree[cur].val = x;4 行未改动return;}void Find ( int x ) {int cur = root;if ( !cur )return;while ( tree[cur].ch[x > tree[cur].val] && x != tree[cur].val )cur = tree[cur].ch[ x > tree[cur].val];Splay ( cur , 0 );18 行未改动if ( tree[del].cnt > 1 ) {tree[del].cnt--;Splay ( del , 0 );}elsetree[next].ch[0] = 0;return;}int kth ( int x ) {5 行未改动if ( x > tree[y].size + tree[cur].cnt ) {x -= tree[y].size + tree[cur].cnt;cur = tree[cur].ch[1];}elseif ( tree[y].size >= x )cur = y;elsereturn tree[cur].val;}}13 行未改动}else if ( opt == 3 ) {int x = read ();Find ( x );printf ( "%d\n" , tree[tree[root].ch[0]].size );}else if ( opt == 4 ) {int x = read ();printf ( "%d\n" , kth ( x + 1 ) );}else if ( opt == 5 ) {int x = read ();printf ( "%d\n" , tree[Next ( x , 0 )].val );}else if ( opt == 6 ) {int x = read ();printf ( "%d\n" , tree[Next ( x , 1 )].val );}}return 0;}```123456789101112135 行未改动192021222324252627282910 行未改动4041424344454647482 行未改动5152535455565758596061626364656667686970717273747521 行未改动97989910010110210310410535 行未改动1411421431441451461471481491501511521531541551561571581591601611621631641651661674 行未改动17217317417517617717817918018 行未改动1992002012022032042052062075 行未改动21321421521621721821922022122222322413 行未改动238239240241242243244245246247248249250251252253254255256257258259260介绍下本蒟蒻的丑死的码风$qwq$...(码风大概是魔改了神犇$Menci$的)~~在打CF时并不是这个码风~~### 码风概述:1. 所有的```#include```后必须有一个空格,例如```#include <iostream>```2. 无论什么样子的程序,都必须写```cstdio cstring algorithm iostream```这四个头文件。3. 在主程序的```int main()```中要加$void$,即为```int main(void)```4. **一般**不写```using namespace std;```5. 所有的变量必须定义在第一个自定义函数之前,且变量和第一个自定义函数,最后一个自定义函数和$main$之间必须有一个换行6. 每个函数之后尽可能有$return$,7. 在一般情况下,在花括号内的内容不加逗号5 行未改动### 空格:>个人感觉自己的空格比较的~~毒瘤~~。>>1.在每个函数声明时,函数名后的括号与函数名之间必须有一个空格,而且括号内如果需要声明变量,则要先有一个空格,且逗号的前后都必须有一个空格。>>2.在for循环的声明中,每一个字符(变量名除外),都要用空格隔开。>>3.数组内一般不加空格,但是如果有运算符则运算符前后必须有空格。>>4.每个可以前后匹配的括号前后必须有空格。10 行未改动qweqweqweqweqweqweqweqwe;if ( qweqweqweqweqwe ) {qewqweqweqweqweq;qweqweqweqweq;}else {qweqweqweqweq;qweqweqwrreeqwqqwe;qweqewqweqweqewq;2 行未改动}```### 变量:>1.基本所有变量都是全局变量,但有些ans,sum最后统计答案时使用的变量可以定义为局部变量。>2.所有的变量名称都必须与要存储的东西的中文意思有沾边,比如树直接定义为tree而不是T。(极度不能容忍变量名直接为a,b,c,d,e,f,g,的情况。>3.定义N,M等时一般只用N,M为名称而不是MAXN,MAXM.>4.定义的结构体类型在定义变量时必须紧接着声明完成结构体后,并且结构体中变量需要定义一个加一个换行。>5.在变量命名时较长的变量名可以用_来连接,并且大小写交替使用,如```Add_Tree_Val```---把上边所有毒瘤的码风结合起来之后代码大概长这个样子qwq..update:还是加上模板舒服qwq21 行未改动#define PI 3.141592653590#define rint register inttemplate < class T > inline void read ( T &x ) {T s = 0 , w = 1;char ch = getchar ();while ( ch > '9' || ch < '0' ) { if ( ch == '-' ) w = -1; ch = getchar ();}while ( ch >= '0' && ch <= '9' ) { s = s * 10 + ch - '0'; ch = getchar ();}x = s * w;return;}template < class T , typename ...Argc > inline void read ( T &x , Argc &...Args ) {read ( x );read ( Args... );return;}template < class T > inline T max ( T x , T y ) {return x > y ? x : y;}template < class T > inline T min ( T x , T y ) {return x < y ? x : y;}template < class T > inline void abs ( T x ) {return x > 0 ? x : -x;}inline int _read () {int s = 0 , w = 1;char ch = getchar ();while ( ch > '9' || ch < '0' ) { if ( ch == '-' ) w = -1; ch = getchar ();}while ( ch >= '0' && ch <= '9' ) { s = s * 10 + ch - '0'; ch = getchar ();}return s * w;}35 行未改动void Splay ( int x , int goal ) {while ( tree[x].father != goal ) {int y = tree[x].father;int z = tree[y].father;if ( z != goal )( tree[y].ch[0] == x ) ^ ( tree[z].ch[0] == y ) ? rotate ( x ) : rotate ( y );rotate ( x );}if ( goal == 0 )root = x;return;}void insert ( int x ) {int cur = root , father = 0;while ( cur && tree[cur].val != x ) {father = cur;cur = tree[cur].ch[x > tree[cur].val];}if ( cur )tree[cur].cnt++;else {cur = ++tot;if ( father )tree[father].ch[x > tree[father].val] = cur;tree[cur].ch[0] = tree[cur].ch[1] = 0;tree[cur].father = father;tree[cur].val = x;4 行未改动return;}void Find ( int x ) {int cur = root;if ( !cur )return;while ( tree[cur].ch[x > tree[cur].val] && x != tree[cur].val )cur = tree[cur].ch[ x > tree[cur].val];Splay ( cur , 0 );18 行未改动if ( tree[del].cnt > 1 ) {tree[del].cnt--;Splay ( del , 0 );}elsetree[next].ch[0] = 0;return;}int kth ( int x ) {5 行未改动if ( x > tree[y].size + tree[cur].cnt ) {x -= tree[y].size + tree[cur].cnt;cur = tree[cur].ch[1];}elseif ( tree[y].size >= x )cur = y;elsereturn tree[cur].val;}}13 行未改动}else if ( opt == 3 ) {int x = read ();Find ( x );printf ( "%d\n" , tree[tree[root].ch[0]].size );}else if ( opt == 4 ) {int x = read ();printf ( "%d\n" , kth ( x + 1 ) );}else if ( opt == 5 ) {int x = read ();printf ( "%d\n" , tree[Next ( x , 0 )].val );}else if ( opt == 6 ) {int x = read ();printf ( "%d\n" , tree[Next ( x , 1 )].val );}}return 0;}```