QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#863537 | #9870. Items | Williamxzh | WA | 5ms | 10068kb | C++23 | 2.1kb | 2025-01-19 19:00:24 | 2025-01-19 19:00:26 |
Judging History
answer
#include <bits/stdc++.h>
#define il inline
using namespace std;
typedef long long ll;
const ll mod=998244353,p=3,pi=(mod+1)/3,DZD=19260817;
il ll qp(ll a,ll b){
ll ans=1ll;
while(b){
if(b&1) ans=(ans*a)%mod;
a=(a*a)%mod,b>>=1;
}return ans;
}
const int N=(1<<19)+5;
int to[N];
il void change(int n,ll a[]){for(int i=0;i<n;++i) if(i<to[i]) swap(a[i],a[to[i]]);}
il void ntt(int n,ll a[],int t){
ll x,y,w,W;change(n,a);
for(int m=1;m<n;m<<=1){
W=qp((t==1)?p:pi,(mod-1)/(m<<1));
for(int i=0;i<n;i+=(m<<1)){
w=1ll;
for(int j=0;j<m;++j) x=a[i+j],y=a[i+j+m]*w%mod,a[i+j]=(x+y>=mod?x+y-mod:x+y),a[i+j+m]=(x<y?x-y+mod:x-y),w=(w*W)%mod;
}
}
if(t==-1){x=qp(n,mod-2ll);for(int i=0;i<n;++i) a[i]=a[i]*x%mod;}
}
ll b[N],c[N],f[N];
il void qp(ll a[],int n){
int m=1,k=1;ll x,y,z,u,v,w;
while(k<=n*4) k<<=1;
for(int i=0;i<k;++i) to[i]=((to[i>>1]>>1)|((i&1)*(k>>1)));
for(int i=0;i<k;++i) f[i]=(i==n);
for(int i=n*2+1;i<k;++i) a[i]=0;
while(m){
if(m&1){
for(int i=0;i<k;++i) b[i]=a[i];
ntt(k,f,1),ntt(k,b,1);
for(int i=0;i<k;++i) f[i]=f[i]*b[i]%mod;
ntt(k,f,-1);
for(int i=n;i<=n*3;++i) c[i]=f[i];
for(int i=0;i<=n*2;++i) f[i]=c[i+n];
for(int i=n*2+1;i<k;++i) f[i]=0;
}
ntt(k,a,1);
for(int i=0;i<k;++i) a[i]=a[i]*a[i]%mod;
ntt(k,a,-1);
for(int i=n;i<=n*3;++i) c[i]=a[i];
for(int i=0;i<=n*2;++i) a[i]=c[i+n];
for(int i=n*2+1;i<k;++i) a[i]=0;
m>>=1;
}
}
int T,n;ll m,a[N];
bitset<N> vis;
int x,y,z;ll u,v,w;
int main(){
scanf("%d",&T);
while(T--){
scanf("%d%lld",&n,&m);
for(int i=0;i<=n;++i) vis[i]=0;for(int i=0;i<=n*2;++i) a[i]=0;
for(int i=1;i<=n;++i) scanf("%d",&x),vis[x]=1;
for(int i=0;i<=n;++i) if(vis[i]) a[i-(m/n)+n]=DZD;
qp(a,n);
//for(int i=0;i<=n*2;++i) printf("%lld ",f[i]);puts("");
if(f[n+(m%n)]) puts("Yes");
else puts("No");
}
return 0;
}
/*
1
5 11
4 4 4 5 5
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 10064kb
input:
4 5 25 0 0 0 0 5 5 11 4 4 4 5 5 5 0 1 2 3 4 5 5 25 0 1 2 3 4
output:
Yes No No No
result:
ok 4 token(s): yes count is 1, no count is 3
Test #2:
score: -100
Wrong Answer
time: 5ms
memory: 10068kb
input:
1314 1 0 0 1 0 1 1 1 0 1 1 1 2 0 0 0 2 0 0 1 2 0 0 2 2 0 1 0 2 0 1 1 2 0 1 2 2 0 2 0 2 0 2 1 2 0 2 2 2 1 0 0 2 1 0 1 2 1 0 2 2 1 1 0 2 1 1 1 2 1 1 2 2 1 2 0 2 1 2 1 2 1 2 2 2 2 0 0 2 2 0 1 2 2 0 2 2 2 1 0 2 2 1 1 2 2 1 2 2 2 2 0 2 2 2 1 2 2 2 2 2 3 0 0 2 3 0 1 2 3 0 2 2 3 1 0 2 3 1 1 2 3 1 2 2 3 2 0...
output:
Yes No No Yes Yes Yes Yes Yes No No Yes No No No Yes No Yes Yes Yes No Yes No No Yes No Yes Yes Yes No Yes No No No Yes No No Yes Yes Yes Yes No No Yes No No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No No No Yes No No No Yes No No No Yes Yes...
result:
wrong answer expected NO, found YES [18th token]