版本比较
随机化做题记录
正文
增加 12 行删除 12 行
12345678912 行未改动222324252627282930313233343536373839167 行未改动全部展开20720820921021121221321421521621721821964 行未改动28428528628728828929029129210 行未改动30330430530630730830931031139 行未改动3513523533543553563573583594 行未改动36436536636736836937037137259 行未改动4324334344354364374384394405 行未改动44644744844945045145245345496 行未改动551552553554555556557558559426 行未改动全部展开### [1.AT_abc367_f [ABC367F] Rearrange Query](https://atcoder.jp/contests/abc367/tasks/abc367_f)其实就是查询区间本质是否相同。考虑随机和哈希。给每一个数一个特定的权值,权值越大越好,这样的话可以避免哈希冲突,然后如果他们的权值的和相等我们就认为这两个区间本质相同。建议使用```cppmt19937_64 Rand(time(0));```12 行未改动good things we had been drewThat something told me right here talking with you.*///#pragma GCC optimize(1)//#pragma GCC optimize(2)//#pragma GCC optimize(3)#include<bits/stdc++.h>#define rep(i,x,y) for(int i=x;i<=y;++i)#define dep(i,x,y) for(int i=x;i>=y;--i)#define int long long#define N 200005#define endl "\n"#define MAX 1145141919810using namespace std;int n,q,a[N],b[N],x;int vis[N],l,r,L,R;inline void Feather(){167 行未改动全部展开}//扩展所有可能}if(tot==n){cout<<"possible";return;}}cout<<"impossible";}signed main(){Feather();return 0;}```::::64 行未改动if(a[i][j]=='A')A+=qzhi[i];else if(a[i][j]=='B')B+=qzhi[i];else if(a[i][j]=='C')C+=qzhi[i];else D+=qzhi[i];// cout<<A<<' '<<B<<' '<<C<<' '<<D<<endl;HASH[j][0]=A;HASH[j][1]=B;HASH[j][2]=C;HASH[j][3]=D;10 行未改动/*A BA CB DC A*/```::::39 行未改动int ret=0,sgn=0,ch=getchar();while(!isdigit(ch))sgn|=ch=='-',ch=getchar();while(isdigit(ch))ret=ret*10+ch-'0',ch=getchar();return sgn?-ret:ret;}struct Matrix{int M[N][N];void clear(){memset(M,0,sizeof(M));}}A,B,C,D,E;4 行未改动mt19937 Rand(time(0));ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);T=read();while(T--){n=read();E.clear();rep(i,1,n)rep(j,1,n)A.M[i][j]=read();rep(i,1,n)rep(j,1,n)B.M[i][j]=read();59 行未改动int ret=0,sgn=0,ch=getchar();while(!isdigit(ch))sgn|=ch=='-',ch=getchar();while(isdigit(ch))ret=ret*10+ch-'0',ch=getchar();return sgn?-ret:ret;}struct Matrix{int M[N][N];void clear(){memset(M,0,sizeof(M));}}A,B,C;5 行未改动mt19937 Rand(time(0));ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);T=read();while(T--){n=read();rep(i,1,n)rep(j,1,n)A.M[i][j]=read();rep(i,1,n)rep(j,1,n)B.M[i][j]=read();96 行未改动int l=i,r=i+mx-1;if(r<=n&&r>=pos[k]&&(hs[r]^hs[l-1])==pm[mx])++ans;}mx=1;rep(i,pos[k]+1,rr){mx=max(mx,a[i]);int l=i-mx+1,r=i;if(l>=1&&l<=pos[k]&&(hs[r]^hs[l-1])==pm[mx])++ans;}426 行未改动全部展开12345678912 行未改动222324252627282930313233343536373839167 行未改动全部展开20720820921021121221321421521621721821964 行未改动28428528628728828929029129210 行未改动30330430530630730830931031139 行未改动3513523533543553563573583594 行未改动36436536636736836937037137259 行未改动4324334344354364374384394405 行未改动44644744844945045145245345496 行未改动551552553554555556557558559426 行未改动全部展开### [1.AT_abc367_f [ABC367F] Rearrange Query](https://atcoder.jp/contests/abc367/tasks/abc367_f)其实就是查询区间本质是否相同。考虑随机和哈希。给每一个数一个特定的权值,权值越大越好,这样的话可以避免哈希冲突,然后如果他们的权值的和相等我们就认为这两个区间本质相同。建议使用```cppmt19937_64 Rand(time(0));```12 行未改动good things we had been drewThat something told me right here talking with you.*///#pragma GCC optimize(1)//#pragma GCC optimize(2)//#pragma GCC optimize(3)#include<bits/stdc++.h>#define rep(i,x,y) for(int i=x;i<=y;++i)#define dep(i,x,y) for(int i=x;i>=y;--i)#define int long long#define N 200005#define endl "\n"#define MAX 1145141919810using namespace std;int n,q,a[N],b[N],x;int vis[N],l,r,L,R;inline void Feather(){167 行未改动全部展开}//扩展所有可能}if(tot==n){cout<<"possible";return;}}cout<<"impossible";}signed main(){Feather();return 0;}```::::64 行未改动if(a[i][j]=='A')A+=qzhi[i];else if(a[i][j]=='B')B+=qzhi[i];else if(a[i][j]=='C')C+=qzhi[i];else D+=qzhi[i];// cout<<A<<' '<<B<<' '<<C<<' '<<D<<endl;HASH[j][0]=A;HASH[j][1]=B;HASH[j][2]=C;HASH[j][3]=D;10 行未改动/*A BA CB DC A*/```::::39 行未改动int ret=0,sgn=0,ch=getchar();while(!isdigit(ch))sgn|=ch=='-',ch=getchar();while(isdigit(ch))ret=ret*10+ch-'0',ch=getchar();return sgn?-ret:ret;}struct Matrix{int M[N][N];void clear(){memset(M,0,sizeof(M));}}A,B,C,D,E;4 行未改动mt19937 Rand(time(0));ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);T=read();while(T--){n=read();E.clear();rep(i,1,n)rep(j,1,n)A.M[i][j]=read();rep(i,1,n)rep(j,1,n)B.M[i][j]=read();59 行未改动int ret=0,sgn=0,ch=getchar();while(!isdigit(ch))sgn|=ch=='-',ch=getchar();while(isdigit(ch))ret=ret*10+ch-'0',ch=getchar();return sgn?-ret:ret;}struct Matrix{int M[N][N];void clear(){memset(M,0,sizeof(M));}}A,B,C;5 行未改动mt19937 Rand(time(0));ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);T=read();while(T--){n=read();rep(i,1,n)rep(j,1,n)A.M[i][j]=read();rep(i,1,n)rep(j,1,n)B.M[i][j]=read();96 行未改动int l=i,r=i+mx-1;if(r<=n&&r>=pos[k]&&(hs[r]^hs[l-1])==pm[mx])++ans;}mx=1;rep(i,pos[k]+1,rr){mx=max(mx,a[i]);int l=i-mx+1,r=i;if(l>=1&&l<=pos[k]&&(hs[r]^hs[l-1])==pm[mx])++ans;}426 行未改动全部展开