版本比较
题解:P7242 [COCI 2019/2020 #4] Klasika
正文
增加 3 行删除 40 行
17 行未改动18192021222324252627282930313233343536373839404142434445464748495051525354555657582223242539 行未改动65666768106697071727311174757677783 行未改动8283848512386878889903 行未改动17 行未改动// #define faster 1#define pl p<<1#define pr p<<1|1using namespace std;namespace lry{ char buf[MAXSIZE],*p1=buf,*p2=buf; char pbuf[MAXSIZE],*pp=pbuf; inline int gc(){ #if faster return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++; #else return getchar(); #endif } inline void pc(const char &c){ #if faster if(pp-pbuf==MAXSIZE) fwrite(pbuf,1,MAXSIZE,stdout),pp=pbuf;*pp++=c; #else putchar(c); #endif } inline bool blank(const char x){return !(x^32)||!(x^10)||!(x^13)||!(x^9);} inline void read(double &rdx){double t=0;int x=0,s=0,f=1;char c;do c=gc();while(!isdigit(c)&&c!='-'&&c!='.');if (c=='-')f=-1,c=gc();while(isdigit(c)&&c!='.')x=(c^48)+(x<<1)+(x<<3),c=gc();if(c=='.')c=gc();else{rdx=x*f;return;}while(c>='0'&&c<='9')t=t*10+(c^48),s=-~s,c=gc();while(s--)t/=10;rdx=(x+t)*f;} inline void read(string &x){x="";char a=gc();for(;blank(a)&&(a^-1);a=gc());for(;!blank(a)&&(a^-1);a=gc())x+=a;} inline void read(char &x){char a=gc();for(;blank(a)&&(a^-1);a=gc());if(!blank(a)&&(a^-1))x=gc();} inline void read(int &x){int ret=0,f=0;char ch=gc();while(!isdigit(ch)){if(ch=='-')f=1;ch=gc();}while(isdigit(ch)){ret=(ret<<1)+(ret<<3)+(ch^48);ch=gc();}x=(f?-ret:ret);} inline void read(ull &x){ull ret=0,f=0;char ch=gc();while(!isdigit(ch)){if(ch=='-')f=1;ch=gc();}while(isdigit(ch)){ret=(ret<<1)+(ret<<3)+(ch^48);ch=gc();}x=(f?-ret:ret);} template<typename t,typename ...T> inline void read(t &x,T&...y){read(x),read(y...);} inline void write(int x){if(x<0)pc('-'),x=-x;if(x>9)write(x/10);pc(x%10+48);} inline void write(ull x){if(x<0)pc('-'),x=-x;if(x>9)write(x/10);pc(x%10+48);} inline void write(const char *x){fputs(x,stdout);} inline void write(const string &x){fputs(x.c_str(),stdout);} inline void writeln(int x){write(x),pc('\n');} inline void writetr(int x){write(x),pc(' ');} inline void writeln(ull x){write(x),pc('\n');} inline void writetr(ull x){write(x),pc(' ');} inline void writeln(string x){write(x),pc('\n');} inline void writetr(string x){write(x),pc(' ');} template<typename t,typename ...T> inline void write(t x,T...y){write(x),write(y...);}}using namespace lry;constexpr int N=200000+10,M=10000000+10,inf=0x3f3f3f3f;int q,n;int rt[N];int tr[M],son[M][2],tot;39 行未改动 } for(int i:p[x]) ans[Q[i].tim]=query(rt[x],Q[i].y,30,Q[i].tim);}signed main(){ read(q); cin>>q; insert(rt[1],0,30,0); n=1; for(int i=1;i<=q;i++){ string s; int x,y; read(s,x,y); cin>>s>>x>>y; if(s=="Add"){ n++; a[n]=(a[x]^y); G[x].push_back(n);3 行未改动 p[y].push_back(i); } } dfs(1,0); for(int i=1;i<=q;i++) if(Q[i].opt) writeln(ans[i]); for(int i=1;i<=q;i++) if(Q[i].opt) cout<<ans[i]<<endl;; #if faster fwrite(pbuf,1,pp-pbuf,stdout); pp=pbuf; #endif3 行未改动