标题
增加 1 行删除 1 行
1负边权的小玩具1负边权的缺省源
正文
增加 363 行删除 34 行
123456785 行未改动1415161718192021222324258 行未改动34353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410554 行未改动160161162163164165166167168169170171172173174175176177178179180364 行未改动全部展开545546547548549主要是自用。需要的可以自取。::::success[缺省源]:::info[缺省源(6KB)]自带 `freopen`,计时器,随机数生成器,`c++17` 基数排序和 `gcd`。```cpp#include<bits/stdc++.h>#include<immintrin.h>#pragma GCC target("avx2")5 行未改动#include<ext/pb_ds/priority_queue.hpp>#include<ext/rope>#define For(a,b,c) for(int a=b;a<=c;a++)#define Fro(a,b,c) for(int a=b;a>=c;a--)#define ms(a) memset(a,0,sizeof a)#define msinf(a) memset(a,0x3f,sizeof a)#define Pii pair<int,int>#define Inline __inline__#define fi first#define se second#define y1 y1ovo#define y2 y2ovo8 行未改动#define ull unsigned long long#define lll __int128#define ulll __uint128_t#define lld long double#define llld __float128#define Ceil(a,b) ceil(1.0*a/b)#define Floor(a,b) floor(1.0*a/b)#define stdpq std::priority_queue#define pbpq __gnu_pbds::priority_queue#define Fopen(in) freopen(in".in","r",stdin);freopen(in".out","w",stdout);#define Happy io.flush();#define Ending return cerr<<"\nTime Used: "<<fixed<<setprecision(0)<<timer.getTime()<<" ms",0#define LL#ifdef LL#define int long long#define inf 0x3f3f3f3f3f3f3f3f#else#define inf 0x3f3f3f3f#endifusing namespace std;using namespace __gnu_pbds;using namespace __gnu_cxx;namespace fast_IO{const int BS=1<<20;char ib[BS],ob[BS],*p1=ib,*p2=ib,*p3=ob;#ifdef ONLINE_JUDGE#define getchar() ((p1==p2&&(p2=(p1=ib)+fread(ib,1,BS,stdin),p1==p2)?EOF:*p1++))#define putchar(x) ((p3==ob+BS&&(fwrite(ob,p3-ob,1,stdout),p3=ob),*p3++=x))#endif#define cin io#define cout io__inline__ void read(){}__inline__ void write(){}template<typename T>__inline__ bool read(T&s){s=0;int w=1;char c;while(c=getchar(),!isdigit(c)&&c!=EOF)if(c=='-')w=-1;if(c==EOF)return 0;while(isdigit(c))s=s*10+c-48,c=getchar();return s*=w,1;}__inline__ bool read(char&s){while(s=getchar(),isspace(s));return s!=EOF;}__inline__ bool read(char*s){char c;while(c=getchar(),isspace(c));if(c==EOF)return 0;while(!isspace(c))*s++=c,c=getchar();return *s=0,1;}__inline__ bool read(std::string&s){s="";char c;while(c=getchar(),isspace(c));if(c==EOF)return 0;while(!isspace(c))s+=c,c=getchar();return 1;}template<typename T>__inline__ bool read_f(T&x){x=0;T w=1;char c;while(c=getchar(),!isdigit(c)&&c!=EOF)if(c=='-')w=-1;if(c==EOF)return 0;while(isdigit(c))x=x*10+(c^48),c=getchar();if(c=='.'){T f=0,k=1;while(c=getchar(),isdigit(c))f=f*10+(c^48),k*=10;x+=f/k;}x*=w;return 1;}__inline__ bool read(float&x){return read_f(x);}__inline__ bool read(double&x){return read_f(x);}__inline__ bool read(long double&x){return read_f(x);}template<size_t N>__inline__ bool read(std::bitset<N>&b){b.reset();char c;while(c=getchar(),c!='0'&&c!='1'&&c!=EOF);if(c==EOF)return 0;static char buf[N+5];int i=0;do{buf[i++]=c;c=getchar();}while((c=='0'||c=='1')&&i<N);for(int j=0;j<=i-1;j++)if(buf[j]=='1')b[i-1-j]=1;return 1;}template<typename T>__inline__ void write(T x){if(x<0)putchar('-'),x=-x;if(x>9)write(x/10);putchar(x%10+48);}__inline__ void write(char x){putchar(x);}__inline__ void write(char*x){while(*x)putchar(*x++);}__inline__ void write(const char*x){for(int i=0;x[i];i++)putchar(x[i]);}__inline__ void write(std::string x){for(char c:x)putchar(c);}template<typename T>__inline__ void writef(T x,int k){if(x<0)putchar('-'),x=-x;T e=0.5;for(int i=1;i<=k;i++)e/=10;x+=e;unsigned long long n=x;write(n);if(k>0){putchar('.');x-=n;for(int i=1;i<=k;i++){x*=10;int c=(int)x;putchar(c+48);x-=c;}}}[[deprecated("Float detected: use writef(x,k) for precision control")]]__inline__ void write(float x){writef(x,6);}[[deprecated("Float detected: use writef(x,k) for precision control")]]__inline__ void write(long double x){writef(x,6);}[[deprecated("Float detected: use writef(x,k) for precision control")]]__inline__ void write(double x){writef(x,6);}template<size_t N>__inline__ void write(std::bitset<N>b){write(b.to_string());}template<typename T,typename ...Tp>__inline__ void write(T x,Tp ...y){write(x),write(y...);}template<typename T,typename ...Tp>__inline__ void read(T &x,Tp &...y){read(x),read(y...);}struct F{bool s=1;__inline__ void flush(){fwrite(ob,p3-ob,1,stdout);p3=ob;}~F(){flush();}explicit operator bool()const{return s;}}io;template<typename T>__inline__ F&operator>>(F&i,T&b){i.s=read(b);return i;}template<typename T>__inline__ F&operator<<(F&i,T b){write(b);return i;}}using namespace fast_IO;template<typename T> using Set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;template<typename T,typename TT> using Map=gp_hash_table<T,TT>;void freopen(string name="test",int type=1,string aaa="",string bbb=""){if(type==1){freopen((name+".in").c_str(),"r",stdin),freopen((name+".out").c_str(),"w",stdout);}else if(type==2){freopen((name+aaa).c_str(),"r",stdin),freopen((name+bbb).c_str(),"w",stdout);}else if(type==3){freopen((name+aaa).c_str(),"r",stdin),freopen((name+bbb).c_str(),"wb",stdout);}else if(type==4){freopen((name+aaa).c_str(),"wb",stdout);}else{return;}}class Timer{private:ull GetCycleCount(){unsigned hi,lo;__asm__ volatile("rdtsc":"=a"(lo),"=d"(hi));return ((ull)(hi)<<32)|lo;}ull startCycle,startTime;public:void restart(){startCycle=GetCycleCount();startTime=chrono::steady_clock::now().time_since_epoch().count();}ull getCycles(){return GetCycleCount()-startCycle;}double getTime(){return (chrono::steady_clock::now().time_since_epoch().count()-startTime)/1e6;}}timer;class FastRand{private:ull s[4];ull rotl(const ull x,int k){return(x<<k)|(x>>(64-k));}ull next(){const ull res=rotl(s[0]+s[3],23)+s[0];const ull t=s[1]<<17;s[2]^=s[0];s[3]^=s[1];s[1]^=s[2];s[0]^=s[3];s[2]^=t;s[3]=rotl(s[3],45);return res;}public:FastRand(){mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());For(i,0,3)s[i]=rng();}int randint(int l,int r){ull range=(ull)r-l+1,v;if(range==0)return next();ull mask=(1ULL<<(64-__builtin_clzll(range-1)))-1;while((v=(next()&mask))>=range);return v+l;}double frand(double l,double r){const ull x=next();const union {ull i;double d;}u={.i=0x3FF0000000000000ULL|(x>>12)};return (u.d-1.0)*(r-l)+l;}}Rand;ll gcd(ll aa,ll bb){ll a=aa,b=bb;if(!a||!b)return a|b;ll shift=__builtin_ctzll(a|b);a>>=__builtin_ctzll(a);while(b){b>>=__builtin_ctzll(b);if(a>b)swap(a,b);b-=a;}return a<<shift;}Int gcd(Int aa,Int bb){Int a=aa,b=bb;if(!a||!b)return a|b;Int shift=__builtin_ctz(a|b);a>>=__builtin_ctz(a);while(b){b>>=__builtin_ctz(b);if(a>b)swap(a,b);b-=a;}return a<<shift;}constexpr Int N=1e5+5,MOD=998244353;Int main(){timer.restart();Happy Ending;}```::::::info[快读(3KB)]支持读入和输出指定位数的 `float`、`double`、`long double`,所有整数,`bitset`和`string`。使用 `cin` 和 `cout` 进行输入输出,有 `bool` 返回值。若开启 `-DONLINE_JUDGE` 在控制台输入样例后要 `CTRL_Z`。```cppnamespace fast_IO{const int BS=1<<20;char ib[BS],ob[BS],*p1=ib,*p2=ib,*p3=ob;#ifdef ONLINE_JUDGE#define getchar() ((p1==p2&&(p2=(p1=ib)+fread(ib,1,BS,stdin),p1==p2)?EOF:*p1++))#define putchar(x) ((p3==ob+BS&&(fwrite(ob,p3-ob,1,stdout),p3=ob),*p3++=x))#endif#define cin io#define cout io__inline__ void read(){}__inline__ void write(){}template<typename T>__inline__ bool read(T&s){s=0;int w=1;char c;while(c=getchar(),!isdigit(c)&&c!=EOF)if(c=='-')w=-1;if(c==EOF)return 0;while(isdigit(c))s=s*10+c-48,c=getchar();return s*=w,1;}__inline__ bool read(char&s){while(s=getchar(),isspace(s));return s!=EOF;}__inline__ bool read(char*s){char c;while(c=getchar(),isspace(c));if(c==EOF)return 0;while(!isspace(c))*s++=c,c=getchar();return *s=0,1;}__inline__ bool read(std::string&s){s="";char c;while(c=getchar(),isspace(c));if(c==EOF)return 0;while(!isspace(c))s+=c,c=getchar();return 1;}template<typename T>__inline__ bool read_f(T&x){x=0;T w=1;char c;while(c=getchar(),!isdigit(c)&&c!=EOF)if(c=='-')w=-1;if(c==EOF)return 0;while(isdigit(c))x=x*10+(c^48),c=getchar();if(c=='.'){T f=0,k=1;while(c=getchar(),isdigit(c))f=f*10+(c^48),k*=10;x+=f/k;}x*=w;return 1;}__inline__ bool read(float&x){return read_f(x);}__inline__ bool read(double&x){return read_f(x);}__inline__ bool read(long double&x){return read_f(x);}template<size_t N>__inline__ bool read(std::bitset<N>&b){b.reset();char c;while(c=getchar(),c!='0'&&c!='1'&&c!=EOF);if(c==EOF)return 0;static char buf[N+5];int i=0;do{buf[i++]=c;c=getchar();}while((c=='0'||c=='1')&&i<N);for(int j=0;j<=i-1;j++)if(buf[j]=='1')b[i-1-j]=1;return 1;}template<typename T>__inline__ void write(T x){if(x<0)putchar('-'),x=-x;if(x>9)write(x/10);putchar(x%10+48);}__inline__ void write(char x){putchar(x);}__inline__ void write(char*x){while(*x)putchar(*x++);}__inline__ void write(const char*x){for(int i=0;x[i];i++)putchar(x[i]);}__inline__ void write(std::string x){for(char c:x)putchar(c);}template<typename T>__inline__ void writef(T x,int k){if(x<0)putchar('-'),x=-x;T e=0.5;for(int i=1;i<=k;i++)e/=10;x+=e;unsigned long long n=x;write(n);if(k>0){putchar('.');x-=n;for(int i=1;i<=k;i++){x*=10;int c=(int)x;putchar(c+48);x-=c;}}}[[deprecated("Float detected: use writef(x,k) for precision control")]]__inline__ void write(float x){writef(x,6);}[[deprecated("Float detected: use writef(x,k) for precision control")]]__inline__ void write(long double x){writef(x,6);}[[deprecated("Float detected: use writef(x,k) for precision control")]]__inline__ void write(double x){writef(x,6);}template<size_t N>__inline__ void write(std::bitset<N>b){write(b.to_string());}template<typename T,typename ...Tp>__inline__ void write(T x,Tp ...y){write(x),write(y...);}template<typename T,typename ...Tp>__inline__ void read(T &x,Tp &...y){read(x),read(y...);}struct F{bool s=1;__inline__ void flush(){fwrite(ob,p3-ob,1,stdout);p3=ob;}~F(){flush();}explicit operator bool()const{return s;}}io;template<typename T>__inline__ F&operator>>(F&i,T&b){i.s=read(b);return i;}template<typename T>__inline__ F&operator<<(F&i,T b){write(b);return i;}}using namespace fast_IO;```::::::info[随机数生成器(667B)]在随机范围内随机生成若干个数时,效率大约为 `mt19937` 的1.5倍,且绝对均匀。```cppclass FastRand{private:ull s[4];ull rotl(const ull x,int k){return(x<<k)|(x>>(64-k));}ull next(){const ull res=rotl(s[0]+s[3],23)+s[0];const ull t=s[1]<<17;s[2]^=s[0];s[3]^=s[1];s[1]^=s[2];s[0]^=s[3];s[2]^=t;s[3]=rotl(s[3],45);return res;}public:FastRand(){mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());For(i,0,3)s[i]=rng();}int randint(int l,int r){ull range=(ull)r-l+1,v;if(range==0)return next();ull mask=(1ULL<<(64-__builtin_clzll(range-1)))-1;while((v=(next()&mask))>=range);return v+l;}double frand(double l,double r){const ull x=next();const union {ull i;double d;}u={.i=0x3FF0000000000000ULL|(x>>12)};return (u.d-1.0)*(r-l)+l;}}Rand;```:::::::::::success[数据结构]:::info[文艺平衡树(1196B)]FHQ Treap。```cppstruct Node{int l,r,v,val,sz,rev;54 行未改动out(t[id].l);cout<<t[id].v<<" ";out(t[id].r);}Int main(){timer.restart();int n,m;cin>>n>>m;For(i,1,n)rt=merge(rt,newNode(i));while(m--){int l,r;cin>>l>>r;reverse(l,r);}out(rt);Happy Ending;}```::::::info[普通平衡树(76B)]```cpp364 行未改动全部展开`);})();```:::::::12345675 行未改动131415161718192021222324252627282930318 行未改动40414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911054 行未改动165166167168169170171172364 行未改动全部展开537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878主要是自用。需要的可以自取。::::success[缺省源]:::info[缺省源(6KB)]```cpp#include<bits/stdc++.h>#include<immintrin.h>#pragma GCC target("avx2")5 行未改动#include<ext/pb_ds/priority_queue.hpp>#include<ext/rope>#define For(a,b,c) for(int a=b;a<=c;a++)#define Fro(a,b,c) for(int a=b;a>=c;a--)#define Fov(g) for(auto e:g)#define Foe(u) for(int i=hd[u];i!=-1;i=g[i].nxt)#define ms(a) memset(a,0,sizeof (a))#define msinf(a) memset(a,0x3f,sizeof (a))#define mss(a,b) memset(a,b,sizeof (a))#define fill(a,n,k) fill(a+1,a+1+n,k)#define fil(v,k) fill(v.begin(),v.end(),k)#define Pii pair<int,int>#define Inline __inline__#define ppc __builtin_popcount#define ctz __builtin_ctz#define fi first#define se second#define y1 y1ovo#define y2 y2ovo8 行未改动#define ull unsigned long long#define lll __int128#define ulll __uint128_t#define lld long double#define Ceil(a,b) ceil(1.0*a/b)#define Floor(a,b) floor(1.0*a/b)#define stdpq std::priority_queue#define pbpq __gnu_pbds::priority_queue#define Fopen(in) freopen(in".in","r",stdin);freopen(in".out","w",stdout);#define Ending return cerr<<"\nTime Used: "<<fixed<<setprecision(0)<<timer.getTime()<<" ms",0#define LL#ifdef LL#define int long long#define inf 0x3f3f3f3f3f3f3f3f#else#define inf 0x3f3f3f3f#endifusing namespace std;using namespace __gnu_pbds;using namespace __gnu_cxx;namespace fast_IO{constexpr int BITSIZE=114514;char inBuffer[BITSIZE],outBuffer[BITSIZE],*startPtr=inBuffer,*endPtr=inBuffer,*outPtr=outBuffer;#ifdef ONLINE_JUDGE#define getchar() ((startPtr==endPtr&&(endPtr=(startPtr=inBuffer)+fread(inBuffer,1,BITSIZE,stdin),startPtr==endPtr)?EOF:*startPtr++))#endif#define putchar(x) ((outPtr==outBuffer+BITSIZE&&(fwrite(outBuffer,outPtr-outBuffer,1,stdout),outPtr=outBuffer),*outPtr++=x))#define cin io#define cout io#define Happy cout.flush();void read(){}void write(){}template<typename T>bool read(T&s){s=0;int w=1;char c;while(c=getchar(),!isdigit(c)&&c!=EOF)if(c=='-')w=-1;if(c==EOF)return 0;while(isdigit(c))s=s*10+c-48,c=getchar();return s*=w,1;}bool read(char&s){while(s=getchar(),isspace(s));return s!=EOF;}bool read(char*s){char c;while(c=getchar(),isspace(c));if(c==EOF)return 0;while(!isspace(c))*s++=c,c=getchar();return *s=0,1;}bool read(std::string&s){s="";char c;while(c=getchar(),isspace(c));if(c==EOF)return 0;while(!isspace(c))s+=c,c=getchar();return 1;}template<typename T>bool read_f(T&x){x=0;T w=1;char c;while(c=getchar(),!isdigit(c)&&c!=EOF)if(c=='-')w=-1;if(c==EOF)return 0;while(isdigit(c))x=x*10+(c^48),c=getchar();if(c=='.'){T f=0,k=1;while(c=getchar(),isdigit(c))f=f*10+(c^48),k*=10;x+=f/k;}x*=w;return 1;}bool read(float&x){return read_f(x);}bool read(double&x){return read_f(x);}bool read(long double&x){return read_f(x);}template<size_t N>bool read(std::bitset<N>&b){b.reset();char c;while(c=getchar(),c!='0'&&c!='1'&&c!=EOF);if(c==EOF)return 0;static char buf[N+5];int i=0;do{buf[i++]=c;c=getchar();}while((c=='0'||c=='1')&&i<N);for(int j=0;j<=i-1;j++)if(buf[j]=='1')b[i-1-j]=1;return 1;}template<typename T>void write(T x){if(x<0)putchar('-'),x=-x;static char st[45];int tp=0;do st[++tp]=x%10+48,x/=10;while(x);while(tp)putchar(st[tp--]);}void write(char x){putchar(x);}void write(char*x){int l=strlen(x);for(int i=0;i<l;i++)putchar(x[i]);}void write(const char*x){int l=strlen(x);for(int i=0;i<l;i++)putchar(x[i]);}void write(std::string x){for(char c:x)putchar(c);}template<typename T>void writef(T x,int k){if(x<0)putchar('-'),x=-x;x+=0.5*pow(10,-k);ull n=x;write(n);if(k>0){putchar('.');x-=n;For(i,1,k){x*=10;int c=(int)x;putchar(c+48);x-=c;}}}[[deprecated]]void write(float x){writef(x,6);} [[deprecated]]void write(long double x){writef(x,6);} [[deprecated]]void write(double x){writef(x,6);}template<size_t N>void write(std::bitset<N>b){write(b.to_string());}template<typename T,typename ...Tp>void write(T x,Tp ...y){write(x),write(y...);}template<typename T,typename ...Tp>void read(T &x,Tp &...y){read(x),read(y...);}struct FstIO{bool s=1;void flush(){fwrite(outBuffer,outPtr-outBuffer,1,stdout);outPtr=outBuffer;}~FstIO(){flush();}explicit operator bool()const{return s;}}io;template<typename T>FstIO&operator>>(FstIO&i,T&b){i.s=read(b);return i;}template<typename T>FstIO&operator<<(FstIO&i,T b){write(b);return i;}}using namespace fast_IO;template<typename T> using Set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;template<typename T,typename TT> using Map=gp_hash_table<T,TT>;void freopen(string name="test",int type=1,string aaa="",string bbb=""){if(type==1){freopen((name+".in").c_str(),"r",stdin),freopen((name+".out").c_str(),"w",stdout);}else if(type==2){freopen((name+aaa).c_str(),"r",stdin),freopen((name+bbb).c_str(),"w",stdout);}else if(type==3){freopen((name+aaa).c_str(),"r",stdin),freopen((name+bbb).c_str(),"wb",stdout);}else if(type==4){freopen((name+aaa).c_str(),"wb",stdout);}else{return;}}class Timer{private:ull GetCycleCount(){unsigned hi,lo;__asm__ volatile("rdtsc":"=a"(lo),"=d"(hi));return ((ull)(hi)<<32)|lo;}ull startCycle,startTime;public:void restart(){startCycle=GetCycleCount();startTime=chrono::steady_clock::now().time_since_epoch().count();}ull getCycles(){return GetCycleCount()-startCycle;}double getTime(){return (chrono::steady_clock::now().time_since_epoch().count()-startTime)/1e6;}}timer;class FastRand{private:ull s[4];ull rotl(const ull x,int k){return(x<<k)|(x>>(64-k));}ull next(){const ull res=rotl(s[0]+s[3],23)+s[0];const ull t=s[1]<<17;s[2]^=s[0];s[3]^=s[1];s[1]^=s[2];s[0]^=s[3];s[2]^=t;s[3]=rotl(s[3],45);return res;}public:FastRand(){mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());For(i,0,3)s[i]=rng();}int randint(int l,int r){ull range=(ull)r-l+1,v;if(range==0)return next();ull mask=(1ULL<<(64-__builtin_clzll(range-1)))-1;while((v=(next()&mask))>=range);return v+l;}double frand(double l,double r){const union {ull i;double d;}u={.i=0x3FF0000000000000ULL|(next()>>12)};return (u.d-1.0)*(r-l)+l;}}Rand;constexpr int N=1e5+5,MOD=998244353;Int main(){timer.restart();Happy Ending;}```::::::info[快读(3090B)]支持读入和输出指定位数的 `float`、`double`、`long double`,所有整数,`bitset`和`string`。使用 `cin` 和 `cout` 进行输入输出,有 `bool` 返回值。若开启 `-DONLINE_JUDGE` 在控制台输入样例后要 `CTRL_Z`。```cppnamespace fast_IO{constexpr int BITSIZE=114514;char inBuffer[BITSIZE],outBuffer[BITSIZE],*startPtr=inBuffer,*endPtr=inBuffer,*outPtr=outBuffer;#ifdef ONLINE_JUDGE#define getchar() ((startPtr==endPtr&&(endPtr=(startPtr=inBuffer)+fread(inBuffer,1,BITSIZE,stdin),startPtr==endPtr)?EOF:*startPtr++))#endif#define putchar(x) ((outPtr==outBuffer+BITSIZE&&(fwrite(outBuffer,outPtr-outBuffer,1,stdout),outPtr=outBuffer),*outPtr++=x))#define cin io#define cout io#define Happy cout.flush();void read(){}void write(){}template<typename T>bool read(T&s){s=0;int w=1;char c;while(c=getchar(),!isdigit(c)&&c!=EOF)if(c=='-')w=-1;if(c==EOF)return 0;while(isdigit(c))s=s*10+c-48,c=getchar();return s*=w,1;}bool read(char&s){while(s=getchar(),isspace(s));return s!=EOF;}bool read(char*s){char c;while(c=getchar(),isspace(c));if(c==EOF)return 0;while(!isspace(c))*s++=c,c=getchar();return *s=0,1;}bool read(std::string&s){s="";char c;while(c=getchar(),isspace(c));if(c==EOF)return 0;while(!isspace(c))s+=c,c=getchar();return 1;}template<typename T>bool read_f(T&x){x=0;T w=1;char c;while(c=getchar(),!isdigit(c)&&c!=EOF)if(c=='-')w=-1;if(c==EOF)return 0;while(isdigit(c))x=x*10+(c^48),c=getchar();if(c=='.'){T f=0,k=1;while(c=getchar(),isdigit(c))f=f*10+(c^48),k*=10;x+=f/k;}x*=w;return 1;}bool read(float&x){return read_f(x);}bool read(double&x){return read_f(x);}bool read(long double&x){return read_f(x);}template<size_t N>bool read(std::bitset<N>&b){b.reset();char c;while(c=getchar(),c!='0'&&c!='1'&&c!=EOF);if(c==EOF)return 0;static char buf[N+5];int i=0;do{buf[i++]=c;c=getchar();}while((c=='0'||c=='1')&&i<N);for(int j=0;j<=i-1;j++)if(buf[j]=='1')b[i-1-j]=1;return 1;}template<typename T>void write(T x){if(x<0)putchar('-'),x=-x;static char st[45];int tp=0;do st[++tp]=x%10+48,x/=10;while(x);while(tp)putchar(st[tp--]);}void write(char x){putchar(x);}void write(char*x){int l=strlen(x);for(int i=0;i<l;i++)putchar(x[i]);}void write(const char*x){int l=strlen(x);for(int i=0;i<l;i++)putchar(x[i]);}void write(std::string x){for(char c:x)putchar(c);}template<typename T>void writef(T x,int k){if(x<0)putchar('-'),x=-x;x+=0.5*pow(10,-k);ull n=x;write(n);if(k>0){putchar('.');x-=n;For(i,1,k){x*=10;int c=(int)x;putchar(c+48);x-=c;}}}[[deprecated]]void write(float x){writef(x,6);} [[deprecated]]void write(long double x){writef(x,6);} [[deprecated]]void write(double x){writef(x,6);}template<size_t N>void write(std::bitset<N>b){write(b.to_string());}template<typename T,typename ...Tp>void write(T x,Tp ...y){write(x),write(y...);}template<typename T,typename ...Tp>void read(T &x,Tp &...y){read(x),read(y...);}struct FstIO{bool s=1;void flush(){fwrite(outBuffer,outPtr-outBuffer,1,stdout);outPtr=outBuffer;}~FstIO(){flush();}explicit operator bool()const{return s;}}io;template<typename T>FstIO&operator>>(FstIO&i,T&b){i.s=read(b);return i;}template<typename T>FstIO&operator<<(FstIO&i,T b){write(b);return i;}}using namespace fast_IO;```::::::info[随机数生成器(667B)]在随机范围内随机生成若干个数时,效率大约为 `mt19937` 的1.5倍,且足够均匀。```cppclass FastRand{private:ull s[4];ull rotl(const ull x,int k){return(x<<k)|(x>>(64-k));}ull next(){const ull res=rotl(s[0]+s[3],23)+s[0];const ull t=s[1]<<17;s[2]^=s[0];s[3]^=s[1];s[1]^=s[2];s[0]^=s[3];s[2]^=t;s[3]=rotl(s[3],45);return res;}public:FastRand(){mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());For(i,0,3)s[i]=rng();}int randint(int l,int r){ull range=(ull)r-l+1,v;if(range==0)return next();ull mask=(1ULL<<(64-__builtin_clzll(range-1)))-1;while((v=(next()&mask))>=range);return v+l;}double frand(double l,double r){const ull x=next();const union {ull i;double d;}u={.i=0x3FF0000000000000ULL|(x>>12)};return (u.d-1.0)*(r-l)+l;}}Rand;```:::::::::::success[数据结构]:::info[文艺平衡树(1016B)]FHQ Treap。```cppstruct Node{int l,r,v,val,sz,rev;54 行未改动out(t[id].l);cout<<t[id].v<<" ";out(t[id].r);}```::::::info[普通平衡树(76B)]```cpp364 行未改动全部展开`);})();```::::::info[3]放烟花。```java// ==UserScript==// @name Firework Confetti Click & Drag Effect// @namespace http://tampermonkey.net/// @version 1.5.0// @description 按下聚合上升,释放绚丽爆开!支持点击与拖动持续发射,带重力与双色系切换。// @author Gemini_Modified// @match *://*/*// @grant none// ==/UserScript==(function() {'use strict';function fireworkEffect() {let rockets = []; // 存储上升的烟花弹let pieces = []; // 存储爆开的碎屑let cvs, ctx, w, h;// 状态控制let isMouseDown = false;let lastFireTime = 0;const fireInterval = 0; // 拖动发射间隔(毫秒),数值越小越密集const colorThemes = {bluePurple: ["#1E90FF", "#8A2BE2", "#9370DB", "#00BFFF", "#4B0082", "#7B68EE"],redOrange: ["#FF4500", "#FF1493", "#FFD700", "#FF6347", "#DC143C", "#FFA500"]};const GRAVITY = 0.15;const FRICTION = 0.96;cvs = document.createElement("canvas");document.body.appendChild(cvs);cvs.setAttribute("style", "width: 100%; height: 100%; top: 0; left: 0; z-index: 99999; position: fixed; pointer-events: none;");if (cvs.getContext && window.addEventListener) {ctx = cvs.getContext("2d");updateCvsSize();window.addEventListener('resize', updateCvsSize, false);// 核心发射逻辑const spawnRocket = (x, y) => {const now = Date.now();// 只有当时间间隔超过阈值才发射,防止移动过快导致性能问题if (now - lastFireTime > fireInterval) {const themeKey = Math.random() > 0 ? 'bluePurple' : 'redOrange';rockets.push(new Rocket(x, y, colorThemes[themeKey]));lastFireTime = now;}};// 监听按下window.addEventListener("mousedown", (e) => {isMouseDown = true;spawnRocket(e.clientX, e.clientY);}, false);// 监听移动window.addEventListener("mousemove", (e) => {if (isMouseDown) {spawnRocket(e.clientX, e.clientY);}}, false);// 监听释放window.addEventListener("mouseup", () => {isMouseDown = false;}, false);// 监听焦点丢失(防止切屏导致无限发射)window.addEventListener("blur", () => {isMouseDown = false;}, false);requestAnimationFrame(loop);}function updateCvsSize() {cvs.width = window.innerWidth * 2;cvs.height = window.innerHeight * 2;cvs.style.width = window.innerWidth + 'px';cvs.style.height = window.innerHeight + 'px';ctx.scale(2, 2);w = window.innerWidth;h = window.innerHeight;}// --- 第一阶段:上升的烟花弹 ---class Rocket {constructor(x, y, palette) {this.x = x;this.y = y;this.palette = palette;this.vy = -12; // 初始向上速度this.vx = (Math.random() - 0.5) * 4; // 稍微增加横向偏移感this.alive = true;this.targetY = y - (Math.random() * 300 + 300)*1; // 爆炸高度}update() {this.x += this.vx;this.y += this.vy;if (this.y <= this.targetY || this.vy > -1) {this.explode();this.alive = false;}}explode() {for (let i = 0; i < 200; i++) { // 减少单次碎屑数量以提升拖动时的性能pieces.push(new Confetti(this.x, this.y, this.palette));}}draw() {ctx.save();ctx.beginPath();ctx.arc(this.x, this.y, 3, 0, Math.PI * 2);ctx.fillStyle = this.palette[0];ctx.shadowBlur = 15;ctx.shadowColor = this.palette[0];ctx.fill();ctx.restore();}}// --- 第二阶段:爆开的碎屑 ---class Confetti {constructor(x, y, palette) {this.x = x;this.y = y;const angle = Math.random() * Math.PI * 2;const force = (Math.random() * 15 + 0.1) * (Math.random() * 0.1 + 0.9) * (Math.random() * 0.1 + 0.9) * (Math.random() * 0.1 + 0.9) * (Math.random() * 0.1 + 0.9) * (Math.random() * 0.1 + 0.9) * (Math.random() * 0.1 + 0.9) * (Math.random() * 0.1 + 0.9) * (Math.random() * 0.1 + 0.9) * (Math.random() * 0.1 + 0.9) * (Math.random() * 0.1 + 0.9) * (Math.random() * 0.1 + 0.9) * (Math.random() * 0.1 + 0.9) * (Math.random() * 0.1 + 0.9);this.vx = Math.cos(angle) * force;this.vy = Math.sin(angle) * force;this.size = Math.random() * 2 + 2;this.color = palette[Math.floor(Math.random() * palette.length)];this.opacity = 1;this.fade = Math.random() * 0.015 + 0.015;this.rotation = Math.random() * 360;this.rotSpeed = (Math.random() - 0.5) * 20;this.scaleY = 1;}update() {this.vx *= FRICTION;this.vy *= FRICTION;this.vy += GRAVITY;this.x += this.vx;this.y += this.vy;this.rotation += this.rotSpeed;this.scaleY = Math.cos(Date.now() * 0.01 + this.x * 0.5);this.opacity -= this.fade;}draw() {if (this.opacity <= 0) return;ctx.save();ctx.translate(this.x, this.y);ctx.rotate(this.rotation * Math.PI / 180);ctx.scale(1, this.scaleY);ctx.globalAlpha = this.opacity;ctx.fillStyle = this.color;ctx.fillRect(-this.size, -this.size / 2, this.size * 2, this.size);ctx.restore();}}function loop() {ctx.clearRect(0, 0, w, h);for (let i = rockets.length - 1; i >= 0; i--) {rockets[i].update();if (rockets[i].alive) rockets[i].draw();else rockets.splice(i, 1);}for (let i = pieces.length - 1; i >= 0; i--) {pieces[i].update();pieces[i].draw();if (pieces[i].opacity <= 0 || pieces[i].y > h) {pieces.splice(i, 1);}}requestAnimationFrame(loop);}}fireworkEffect();})();```:::::::::::success[工具]:::info[文本加密&解密]```cpp#include<bits/stdc++.h>#include<immintrin.h>#pragma GCC target("avx2")#include<ext/pb_ds/assoc_container.hpp>#include<ext/pb_ds/tree_policy.hpp>#include<ext/pb_ds/hash_policy.hpp>#include<ext/pb_ds/trie_policy.hpp>#include<ext/pb_ds/list_update_policy.hpp>#include<ext/pb_ds/priority_queue.hpp>#include<ext/rope>#define For(a,b,c) for(int a=b;a<=c;a++)#define Fro(a,b,c) for(int a=b;a>=c;a--)#define ms(a) memset(a,0,sizeof a)#define msinf(a) memset(a,0x3f,sizeof a)#define Pii pair<int,int>#define Inline __inline__#define fi first#define se second#define y1 y1ovo#define y2 y2ovo#define j1 j1ovo#define j2 j2ovo#define mp make_pair#define pb push_back#define eb emplace_back#define Int signed#define uint unsigned#define ll long long#define ull unsigned long long#define lll __int128#define ulll __uint128_t#define lld long double#define llld __float128#define Ceil(a,b) ceil(1.0*a/b)#define Floor(a,b) floor(1.0*a/b)#define stdpq std::priority_queue#define pbpq __gnu_pbds::priority_queue#define Fopen(in) freopen(in".in","r",stdin);freopen(in".out","w",stdout);#define Happy io.flush();#define Ending return cerr<<"\nTime Used: "<<fixed<<setprecision(0)<<timer.getTime()<<" ms",0#define LL#ifdef LL#define int long long#define inf 0x3f3f3f3f3f3f3f3f#else#define inf 0x3f3f3f3f#endifusing namespace std;using namespace __gnu_pbds;using namespace __gnu_cxx;namespace fast_IO{const int BS=1<<20;char ib[BS],ob[BS],*p1=ib,*p2=ib,*p3=ob;#ifdef ONLINE_JUDGE#define getchar() ((p1==p2&&(p2=(p1=ib)+fread(ib,1,BS,stdin),p1==p2)?EOF:*p1++))#define putchar(x) ((p3==ob+BS&&(fwrite(ob,p3-ob,1,stdout),p3=ob),*p3++=x))#endif#define isd(c) (c>47&&c<58)#define iss(c) (c<33)//#define cin io//#define cout iotemplate<typename T>inline bool read(T&s){s=0;int w=1;char c;while(c=getchar(),!isd(c)&&c!=EOF)if(c=='-')w=-1;if(c==EOF)return 0;while(isd(c))s=s*10+c-48,c=getchar();return s*=w,1;}inline bool read(char&s){while(s=getchar(),iss(s));return s!=EOF;}inline bool read(char*s){char c;while(c=getchar(),iss(c));if(c==EOF)return 0;while(!iss(c))*s++=c,c=getchar();return *s=0,1;}inline bool read(std::string&s){s="";char c;while(c=getchar(),iss(c));if(c==EOF)return 0;while(!iss(c))s+=c,c=getchar();return 1;}template<typename T>inline bool read_f(T&x){x=0;T w=1;char c;while(c=getchar(),!isd(c)&&c!=EOF)if(c=='-')w=-1;if(c==EOF)return 0;while(isd(c))x=x*10+(c^48),c=getchar();if(c=='.'){T f=0,k=1;while(c=getchar(),isd(c))f=f*10+(c^48),k*=10;x+=f/k;}x*=w;return 1;}inline bool read(float&x){return read_f(x);}inline bool read(double&x){return read_f(x);}inline bool read(long double&x){return read_f(x);}template<size_t N>inline bool read(std::bitset<N>&b){b.reset();char c;while(c=getchar(),c!='0'&&c!='1'&&c!=EOF);if(c==EOF)return 0;static char buf[N+5];int i=0;do{buf[i++]=c;c=getchar();}while((c=='0'||c=='1')&&i<N);For(j,0,i-1)if(buf[j]=='1')b[i-1-j]=1;return 1;}template<typename T>inline void write(T x){if(x<0)putchar('-'),x=-x;if(x>9)write(x/10);putchar(x%10+48);}inline void write(char x){putchar(x);}inline void write(char*x){while(*x)putchar(*x++);}inline void write(const char*x){for(int i=0;x[i];i++)putchar(x[i]);}inline void write(std::string x){for(char c:x)putchar(c);}template<typename T>inline void write(T x,int k){if(x<0)putchar('-'),x=-x;T e=0.5;For(i,1,k)e/=10;x+=e;ull n=(ull)x;write(n);if(k>0){putchar('.');x-=n;For(i,1,k){x*=10;int c=(int)x;putchar(c+48);x-=c;}}}[[deprecated("Float detected: use write(x,k) for precision control")]]inline void write(float x){write(x,6);}[[deprecated("Float detected: use write(x,k) for precision control")]]inline void write(long double x){write(x,6);}[[deprecated("Float detected: use write(x,k) for precision control")]]inline void write(double x){write(x,6);}template<size_t N>inline void write(std::bitset<N>b){write(b.to_string());}struct F{bool s=1;inline void flush(){fwrite(ob,p3-ob,1,stdout);p3=ob;}~F(){flush();}explicit operator bool()const{return s;}}io;template<typename T>inline F&operator>>(F&i,T&b){i.s=read(b);return i;}template<typename T>inline F&operator<<(F&i,T b){write(b);return i;}}using namespace fast_IO;template<typename T> using Set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;template<typename T,typename TT> using Map=gp_hash_table<T,TT>;void freopen(string name="test",int type=1,string aaa="",string bbb=""){if(type==1){freopen((name+".in").c_str(),"r",stdin),freopen((name+".out").c_str(),"w",stdout);}else if(type==2){freopen((name+aaa).c_str(),"r",stdin),freopen((name+bbb).c_str(),"w",stdout);}else if(type==3){freopen((name+aaa).c_str(),"r",stdin),freopen((name+bbb).c_str(),"wb",stdout);}else if(type==4){freopen((name+aaa).c_str(),"wb",stdout);}else{return;}}class Timer{private:ull GetCycleCount(){unsigned hi,lo;__asm__ volatile("rdtsc":"=a"(lo),"=d"(hi));return ((ull)(hi)<<32)|lo;}ull startCycle,startTime;public:void restart(){startCycle=GetCycleCount();startTime=chrono::steady_clock::now().time_since_epoch().count();}ull getCycles(){return GetCycleCount()-startCycle;}double getTime(){return (chrono::steady_clock::now().time_since_epoch().count()-startTime)/1e6;}}timer;class Random{private:mt19937 randGen{random_device{}()};public:int randint(int l,int r){uniform_int_distribution<int> randDis(l,r);return randDis(randGen);}double frand(double l,double r){uniform_real_distribution<double> randDis(l,r); return randDis(randGen);}}Rand;ll gcd(ll aa,ll bb){ll a=aa,b=bb;if(!a||!b)return a|b;ll shift=__builtin_ctzll(a|b);a>>=__builtin_ctzll(a);while(b){b>>=__builtin_ctzll(b);if(a>b)swap(a,b);b-=a;}return a<<shift;}Int gcd(Int aa,Int bb){Int a=aa,b=bb;if(!a||!b)return a|b;Int shift=__builtin_ctz(a|b);a>>=__builtin_ctz(a);while(b){b>>=__builtin_ctz(b);if(a>b)swap(a,b);b-=a;}return a<<shift;}constexpr Int N=5e5+5,MOD=998244353;#if __cplusplus > 201703Lnamespace Radix{int c[65536];template<typename T>void run(T* a,int n){static T t[N];T *x=a,*y=t,m=(T)1<<(sizeof(T)*8-1);For(i,0,n-1)x[i]^=m;for(int p=0;p<(int)sizeof(T)*8;p+=16){ms(c);For(i,0,n-1)c[(x[i]>>p)&0xFFFF]++;For(i,1,65535)c[i]+=c[i-1];Fro(i,n-1,0)y[--c[(x[i]>>p)&0xFFFF]]=x[i];swap(x,y);}if(x!=a)For(i,0,n-1)a[i]=x[i];For(i,0,n-1)a[i]^=m;}}template<typename T,typename Cmp=std::less<T>>void Sort(T* st,T* ed,Cmp cmp=Cmp()){int n=ed-st;if(n<2)Happy;if(n<131072||!is_integral_v<T>||!is_same_v<Cmp,std::less<T>>){sort(st,ed,cmp);Happy;}Radix::run(st,n);}#endifstruct SimpleBlockCipher{static ull hsh(string s){ull h=0xcbf29ce484222325;for(char c:s)h^=(ull)c,h*=0x100000001b3;return h;}static ull nxt(ull&s){return s=s*6364136223846793005ULL+1442695040888963407ULL;}static ull rol(ull v,int s){return(v<<s)|(v>>(64-s));}static vector<ull> enc(string t,string k){vector<ull> res;ull s=hsh(k);int len=t.length();for(int i=0;i<len;i+=8){ull b=0;char buf[8]={0};memcpy(buf,t.data()+i,min(8LL,len-i));memcpy(&b,buf,8);b^=nxt(s);b=rol(b,13);res.pb(b);}return res;}static ull ror(ull v,int s){return(v>>s)|(v<<(64-s));}static string dec(const vector<ull>&c,const string&k){string res="";ull s=hsh(k);for(ull b:c){ull msk=nxt(s);b=ror(b,13);b^=msk;char buf[8];memcpy(buf,&b,8);For(i,0,7)res+=buf[i];}size_t p=res.find_last_not_of('\0');return(p!=string::npos)?res.substr(0,p+1):"";}};string s,k,tmp;void encrypt(){freopen("encoded.txt","w",stdout);while(getline(cin,tmp))s+=tmp+'\n';if(!s.empty()&&s.back()=='\n')s.pop_back();int p=s.find_last_of('\n');if(p!=string::npos)k=s.substr(p+1),s=s.substr(0,p);vector<ull> res=SimpleBlockCipher::enc(s,k);for(ull v:res)cout<<v<<" ";}void decrypt(){vector<ull> encoded;cin>>k;freopen("encoded.txt","r",stdin);freopen("decoded.txt","w",stdout);ull awa=0;while(cin>>awa)encoded.pb(awa);cout<<SimpleBlockCipher::dec(encoded,k)<<'\n';}Int main(){timer.restart();decrypt();Happy Ending;}```:::::::