正文
增加 5 行删除 8 行
10 行未改动11121314151617181920212223242538 行未改动6465666768697071726 行未改动79808182838485868788141 行未改动全部展开230231232233234235236237238640 行未改动全部展开10 行未改动#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 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__38 行未改动#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;6 行未改动```::::::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++))141 行未改动全部展开::::::info[树链剖分(3182B)]```cppvector<int> g[N];int n,m,r,p,cnt;int dep[N],fa[N],sz[N],ch[N],q[N],a[N],id[N],top[N];void dfs1(int u,int fat,int dp){sz[u]=1;dep[u]=dp;640 行未改动全部展开10 行未改动11121314151617181920212223242538 行未改动64656667686970716 行未改动7879808182838485141 行未改动全部展开227228229230231232233234235640 行未改动全部展开10 行未改动#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=(int)b;a<=(int)(c);a++)#define Fro(a,b,c) for(int a=(int)b;a>=(int)(c);a--)#define Fov(e,g) for(auto e:g)#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 mcp(a,b) memcpy(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__38 行未改动#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;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;6 行未改动```::::::info[快读(3090B)]```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++))141 行未改动全部展开::::::info[树链剖分(3182B)]```cppvector<int> g[N];int n,m,rint dep[N],fa[N],sz[N],ch[N],q[N],a[N],id[N],top[N];void dfs1(int u,int fat,int dp){sz[u]=1;dep[u]=dp;640 行未改动全部展开