結果
問題 | No.206 数の積集合を求めるクエリ |
ユーザー | LayCurse |
提出日時 | 2015-05-10 21:38:44 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 10,564 bytes |
コンパイル時間 | 1,810 ms |
コンパイル使用メモリ | 169,432 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-05 22:03:56 |
合計ジャッジ時間 | 3,029 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
コンパイルメッセージ
main.cpp: In member function ‘unsigned int mint::setmod(unsigned int)’: main.cpp:47:571: warning: no return statement in function returning non-void [-Wreturn-type] 47 | unsigned setmod(unsigned m){W=32;md=m;R=(1ULL<<W)%md;RR=(ull)R*R%md;switch(m){case 104857601:Rinv=2560000;mdninv=104857599;break;case 998244353:Rinv=232013824;mdninv=998244351;break;case 1000000007:Rinv=518424770;mdninv=2226617417U;break;case 1000000009:Rinv=171601999;mdninv=737024967;break;case 1004535809:Rinv=234947584;mdninv=1004535807;break;case 1007681537:Rinv=236421376;mdninv=1007681535;break;case 1012924417:Rinv=238887936;mdninv=1012924415;break;case 1045430273:Rinv=254466304;mdninv=1045430271;break;case 1051721729:Rinv=257538304;mdninv=1051721727;break;}} | ^ main.cpp: In function ‘void reader(double*)’: main.cpp:15:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | void reader(double *x){scanf("%lf",x);} | ~~~~~^~~~~~~~~
ソースコード
#include<bits/stdc++.h> using namespace std; #define REP(i,a,b) for(i=a;i<b;i++) #define rep(i,n) REP(i,0,n) #define mygc(c) (c)=getchar_unlocked() #define mypc(c) putchar_unlocked(c) #define ll long long #define ull unsigned ll void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);} void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);} void reader(double *x){scanf("%lf",x);} int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;} template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);} template <class T, class S, class U> void reader(T *x, S *y, U *z){reader(x);reader(y);reader(z);} template <class T, class S, class U, class V> void reader(T *x, S *y, U *z, V *w){reader(x);reader(y);reader(z);reader(w);} void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);} void writer(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);} void writer(double x, char c){printf("%.15f",x);mypc(c);} void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);} void writer(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);} template<class T> void writerLn(T x){writer(x,'\n');} template<class T, class S> void writerLn(T x, S y){writer(x,' ');writer(y,'\n');} template<class T, class S, class U> void writerLn(T x, S y, U z){writer(x,' ');writer(y,' ');writer(z,'\n');} template<class T> void writerArr(T x[], int n){int i;if(!n){mypc('\n');return;}rep(i,n-1)writer(x[i],' ');writer(x[n-1],'\n');} ull pw(ull a, ull b, ull m){ull r=1;while(b){if(b&1)r=r*a%m;b>>=1;a=a*a%m;}return r;} int get_inv(ll a, int md){ll t=a,s=md,u=1,v=0,e;while(s){e=t/s;t-=e*s;u-=e*v;swap(t,s);swap(u,v);}if(u<0)u+=md;return u;} void mfft(int n, int x[], int root, int md, void *mem){int i,j,I,J,K,s=1,p,w,v,u,a,b,c,d,A,B,C,D,*y=(int*)mem;p=pw(root,(md-1)/4*3,md);root=pw(root,(md-1)/n,md);while(n>2){I=n/4;J=I+I;K=I+J;w=1;rep(i,I){v=(ll)w*w%md;u=(ll)w*v%md;rep(j,s){a=x[j+s*i];b=x[j+s*(i+I)];c=x[j+s*(i+J)];d=x[j+s*(i+K)];A=a+c;if(A>=md)A-=md;B=a-c;if(B<0)B+=md;C=b+d;if(C>=md)C-=md;D=b-d;if(D<0)D+=md;D=(ll)D*p%md;y[j+s*4*i]=A+C;y[j+s*(4*i+1)]=(ll)w*(B-D)%md;y[j+s*(4*i+2)]=(ll)v*(A-C)%md;y[j+s*(4*i+3)]=(ll)u*(B+D)%md;if(y[j+s*4*i]>=md)y[j+s*4*i]-=md;if(y[j+s*(4*i+1)]<0)y[j+s*(4*i+1)]+=md;if(y[j+s*(4*i+2)]<0)y[j+s*(4*i+2)]+=md;}w = (ll)w*root%md;}n/=4;s*=4;root=(ll)root*root%md;root=(ll)root*root%md;swap(x,y);}if(n==2){rep(i,s){y[i]=x[i]+x[i+s];if(y[i]>=md)y[i]-=md;y[i+s]=x[i]-x[i+s];if(y[i+s]<0)y[i+s]+=md;}n/=2;s*=2;root=(ll)root*root%md;swap(x,y);}rep(i,s)y[i]=x[i];} void mfftinv(int n, int x[], int root, int md, void *mem){int i,j,I,J,K,s=1,p,w,v,u,a,b,c,d,A,B,C,D,*y=(int*)mem;root=get_inv(root,md);p=pw(root,(md-1)/4,md);root=pw(root,(md-1)/n,md);while(n>2){I=n/4;J=I+I;K=I+J;w=1;rep(i,I){v=(ll)w*w%md;u=(ll)w*v%md;rep(j,s){a=x[j+s*i];b=x[j+s*(i+I)];c=x[j+s*(i+J)];d=x[j+s*(i+K)];A=a+c;if(A>=md)A-=md;B=a-c;if(B<0)B+=md;C=b+d;if(C>=md)C-=md;D=b-d;if(D<0)D+=md;D=(ll)D*p%md;y[j+s*4*i]=A+C;y[j+s*(4*i+1)]=(ll)w*(B+D)%md;y[j+s*(4*i+2)]=(ll)v*(A-C)%md;y[j+s*(4*i+3)]=(ll)u*(B-D)%md;if(y[j+s*4*i]>=md)y[j+s*4*i]-=md;if(y[j+s*(4*i+2)]<0)y[j+s*(4*i+2)]+=md;if(y[j+s*(4*i+3)]<0)y[j+s*(4*i+3)]+=md;}w=(ll)w*root%md;}n/=4;s*=4;root=(ll)root*root%md;root=(ll)root*root%md;swap(x,y);}if(n==2){rep(i,s){y[i]=x[i]+x[i+s];if(y[i]>=md)y[i]-=md;y[i+s]=x[i]-x[i+s];if(y[i+s]<0)y[i+s]+=md;}n/=2;s*=2;root=(ll)root*root%md;swap(x,y);}rep(i,s)y[i]=x[i];} template<class S, class T, class U> void modconvolution(S A[], int As, T B[], int Bs, U res[], int Rs, void *mem, int md, int root, int ordered=1){int i,n,k,r,*a,*b;n=max(As+Bs,Rs);for(k=1;k<n;k*=2);a=(int*)mem;b=a+k;mem=b+k;if(ordered){rep(i,As)a[i]=A[i];rep(i,Bs)b[i]=B[i];}else{rep(i,As){a[i]=A[i]%md;if(a[i]<0)a[i]+=md;}rep(i,Bs){b[i]=B[i]%md;if(b[i]<0)b[i]+=md;}}REP(i,As,k)a[i]=0;REP(i,Bs,k)b[i]=0;mfft(k,a,root,md,mem);mfft(k,b,root,md,mem);rep(i,k)a[i]=(ll)a[i]*b[i]%md;mfftinv(k,a,root,md,mem);r=get_inv(k,md);rep(i,Rs)res[i]=(ll)a[i]*r%md;} template<class S, class T> void modconvolution(S A[], int As, T res[], int Rs, void *mem, int md, int root, int ordered=1){int i,n,k,r,*a;n=max(2*As,Rs);for(k=1;k<n;k*=2);a=(int*)mem;mem=a+k;if(ordered)rep(i,As)a[i]=A[i];else rep(i,As){a[i]=A[i]%md;if(a[i]<0)a[i]+=md;}REP(i,As,k)a[i]=0;mfft(k,a,root,md,mem);rep(i,k)a[i]=(ll)a[i]*a[i]%md;mfftinv(k,a,root,md,mem);r=get_inv(k,md);rep(i,Rs)res[i]=(ll)a[i]*r%md;} char memarr[77000000]; void *mem = memarr; #define MD 1004535809 struct mint{ static unsigned md, W, R, Rinv, mdninv, RR; unsigned val; mint(){}mint(int a){val=mulR(a);}mint(unsigned a){val=mulR(a);}mint(ll a){val=mulR(a);}mint(ull a){val=mulR(a);} unsigned setmod(unsigned m){W=32;md=m;R=(1ULL<<W)%md;RR=(ull)R*R%md;switch(m){case 104857601:Rinv=2560000;mdninv=104857599;break;case 998244353:Rinv=232013824;mdninv=998244351;break;case 1000000007:Rinv=518424770;mdninv=2226617417U;break;case 1000000009:Rinv=171601999;mdninv=737024967;break;case 1004535809:Rinv=234947584;mdninv=1004535807;break;case 1007681537:Rinv=236421376;mdninv=1007681535;break;case 1012924417:Rinv=238887936;mdninv=1012924415;break;case 1045430273:Rinv=254466304;mdninv=1045430271;break;case 1051721729:Rinv=257538304;mdninv=1051721727;break;}} unsigned mulR(unsigned a){return(ull)a*R%md;}unsigned mulR(int a){if(a<0)a=a%md+md;return mulR((unsigned)a);}unsigned mulR(ull a){return mulR((unsigned)(a%md));}unsigned mulR(ll a){if(a<0)a=a%md+md;return mulR((unsigned)a);} unsigned reduce(unsigned T){unsigned m=T*mdninv;unsigned t=(unsigned)((T+(ull)m*md)>>W);if(t>=md)t-=md;return t;}unsigned reduce(ull T){unsigned m=(unsigned)T*mdninv;unsigned t=(unsigned)((T+(ull)m*md)>>W);if(t>=md)t-=md;return t;} unsigned get(){return reduce(val);} mint&operator+=(mint a){val+=a.val;if(val>=md)val-=md;return*this;}mint&operator-=(mint a){if(val<a.val)val=val+md-a.val;else val-=a.val;return*this;}mint&operator*=(mint a){val=reduce((ull)val*a.val);return*this;}mint&operator/=(mint a){return*this*=a.inverse();} mint operator+(mint a){return mint(*this)+=a;}mint operator-(mint a){return mint(*this)-=a;}mint operator*(mint a){return mint(*this)*=a;}mint operator/(mint a){return mint(*this)/=a;} mint operator+(int a){return mint(*this)+=mint(a);}mint operator-(int a){return mint(*this)-=mint(a);}mint operator*(int a){return mint(*this)*=mint(a);}mint operator/(int a){return mint(*this)/=mint(a);} mint operator+(ll a){return mint(*this)+=mint(a);}mint operator-(ll a){return mint(*this)-=mint(a);}mint operator*(ll a){return mint(*this)*=mint(a);}mint operator/(ll a){return mint(*this)/=mint(a);} mint operator-(void){mint res;if(val)res.val=md-val;else res.val=0;return res;} operator bool(void){return val!=0;}operator int(void){return get();}operator ll(void){return get();} mint inverse(){int a=val,b=md,u=1,v=0,t;mint r;while(b){t=a/b;a-=t*b;swap(a,b);u-=t*v;swap(u,v);}if(u<0)u+=md;r.val=(ull)u*RR%md;return r;} mint pw(ull b){mint a(*this),r;r.val=R;while(b){if(b&1)r*=a;b>>=1;a*=a;}return r;} }; unsigned mint::md, mint::W, mint::R, mint::Rinv, mint::mdninv, mint::RR; mint operator+(int a, mint b){return mint(a)+=b;}mint operator-(int a, mint b){return mint(a)-=b;}mint operator*(int a, mint b){return mint(a)*=b;}mint operator/(int a, mint b){return mint(a)/=b;} mint operator+(ll a, mint b){return mint(a)+=b;}mint operator-(ll a, mint b){return mint(a)-=b;}mint operator*(ll a, mint b){return mint(a)*=b;}mint operator/(ll a, mint b){return mint(a)/=b;} mint mval[10000], minv[10000]; void mint_init(int md=MD, mint val[]=mval, int vals=10000, mint inv[]=minv, int invs=10000){int i;val[0].setmod(md);val[0].val=0;REP(i,1,vals){val[i].val=val[i-1].val+mint::R;if(val[i].val >=md)val[i].val-=md;}inv[1].val=1;REP(i,2,invs){inv[i].val=md-((ll)(md/i)*inv[md%i].val%md);}REP(i,1,invs)inv[i].val=(ull)inv[i].val*mint::R%md;} void mfft(int n, mint x[], mint root, void *mem){int i,j,X,Y,Z,s=1;mint I,J,K,a,b,c,d,A,B,C,D,t,*y=(mint*)mem;t=root.pw((mint::md-1)/4*3);root=root.pw((mint::md-1)/n);while(n>2){X=n/4;Y=X+X;Z=X+Y;I.val=mint::R;rep(i,X){J=I*I;K=I*J;rep(j,s)a=x[j+s*i],b=x[j+s*(i+X)],c=x[j+s*(i+Y)],d=x[j+s*(i+Z)],A=a+c,B=a-c,C=b+d,D=(b-d)*t,y[j+s*4*i]=A+C,y[j+s*(4*i+1)]=I*(B-D),y[j+s*(4*i+2)]=J*(A-C),y[j+s*(4*i+3)]=K*(B+D);I*=root;}n/=4;s*=4;root*=root;root*=root;swap(x,y);}if(n==2){rep(i,s)y[i]=x[i]+x[i+s],y[i+s]=x[i]-x[i+s];n/=2;s*=2;root*=root;swap(x,y);}rep(i,s)y[i]=x[i];} void mfftinv(int n, mint x[], mint root, void *mem){int i,j,X,Y,Z,s=1;mint I,J,K,a,b,c,d,A,B,C,D,t,*y=(mint*)mem;root=root.inverse();t=root.pw((mint::md-1)/4);root=root.pw((mint::md-1)/n);while(n>2){X=n/4;Y=X+X;Z=X+Y;I.val=mint::R;rep(i,X){J=I*I;K=I*J;rep(j,s)a=x[j+s*i],b=x[j+s*(i+X)],c=x[j+s*(i+Y)],d=x[j+s*(i+Z)],A=a+c,B=a-c,C=b+d,D=(b-d)*t,y[j+s*4*i]=A+C,y[j+s*(4*i+1)]=I*(B+D),y[j+s*(4*i+2)]=J*(A-C),y[j+s*(4*i+3)]=K*(B-D);I*=root;}n/=4;s*=4;root*=root;root*=root;swap(x,y);}if(n==2){rep(i,s)y[i]=x[i]+x[i+s],y[i+s]=x[i]-x[i+s];n/=2;s*=2;root*=root;swap(x,y);}rep(i,s)y[i]=x[i];} void modconvolution(mint A[], int As, mint B[], int Bs, mint res[], int Rs, void *mem, mint root){int i,n,m;mint*a,*b,r;n=max(As+Bs,Rs);for(m=1;m<n;m*=2);a=(mint*)mem;b=a+m;mem=b+m;rep(i,As)a[i]=A[i];REP(i,As,m)a[i].val=0;rep(i,Bs)b[i]=B[i];REP(i,Bs,m)b[i].val=0;mfft(m,a,root,mem);mfft(m,b,root,mem);rep(i,m)a[i]*=b[i];mfftinv(m,a,root,mem);r=mint(m).inverse();rep(i,Rs)res[i]=a[i]*r;} void modconvolution(mint A[], int As, mint res[], int Rs, void *mem, mint root){int i,n,m;mint*a,r;n=max(2*As, Rs);for(m=1;m<n;m*=2);a=(mint*)mem;mem=a+m;rep(i,As)a[i]=A[i];REP(i,As,m)a[i].val=0;mfft(m,a,root,mem);rep(i,m)a[i]*=a[i];mfftinv(m,a,root,mem);r=mint(m).inverse();rep(i,Rs)res[i]=a[i]*r;} int L, M, N, Q; mint A[100001], B[100001], C[200001]; int main(){ int i, j, k; mint_init(); reader(&L,&M,&N); rep(i,L){ reader(&k); A[k-1] = mval[1]; } rep(i,M){ reader(&k); B[N-k] = mval[1]; } reader(&Q); modconvolution(A, N, B, N, C, 2*N, mem, mval[3]); rep(i,Q) writerLn((int)C[N-1+i]); return 0; }