QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#820216 | #9870. Items | Wuyanru | WA | 507ms | 13216kb | C++14 | 3.0kb | 2024-12-18 20:10:29 | 2024-12-18 20:10:35 |
Judging History
answer
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f3f3f3f3fll
#define debug(x) cerr<<#x<<"="<<x<<endl
using namespace std;
using ll=long long;
using ld=long double;
using pli=pair<ll,int>;
using pi=pair<int,int>;
template<typename A>
using vc=vector<A>;
inline int read()
{
int s=0,w=1;char ch;
while((ch=getchar())>'9'||ch<'0') if(ch=='-') w=-1;
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
inline ll lread()
{
ll s=0,w=1;char ch;
while((ch=getchar())>'9'||ch<'0') if(ch=='-') w=-1;
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
const int mod=998244353;
const int G=3;
const int NG=(mod+1)/G;
int wh[600005];
ll f[600005];
ll g[600005];
int w[100005];
int n,m;
inline ll qow(ll a,ll b)
{
ll ans=1;
while(b)
{
if(b&1) ans=ans*a%mod;
a=a*a%mod;
b>>=1;
}
return ans;
}
inline void NTT(ll *f,int L,bool dft)
{
for(int i=0;i<(1<<L);i++) if(i<wh[i]) swap(f[i],f[wh[i]]);
for(int len=1;len<=L;len++)
{
ll step=qow(dft?G:NG,(mod-1)>>len);
for(int l=0,r=1<<len;l<(1<<L);l=r,r+=1<<len)
{
ll now=1;
for(int i=l,j=l+(1<<(len-1));j<r;i++,j++)
{
ll num=now*f[j]%mod;
f[j]=(f[i]-num)%mod;
f[i]=(f[i]+num)%mod;
now=now*step%mod;
}
}
}
if(!dft)
{
ll num=qow(1<<L,mod-2);
for(int i=0;i<(1<<L);i++) f[i]=f[i]*num%mod;
}
}
struct poly
{
// [m-n,m+n]
// a[i] -> m-n+i
bool a[200005];
poly(){ memset(a,0,sizeof(a));}
inline void clear(){ memset(a,0,sizeof(a));}
poly operator * (poly b)
{
int L=0;
while((1<<L)<=4*n) L++;
memset(f,0,sizeof(ll)*(1<<L));
memset(g,0,sizeof(ll)*(1<<L));
for(int i=0;i<=2*n;i++) f[i]=a[i],g[i]=b.a[i];
for(int i=0;i<(1<<L);i++) wh[i]=(wh[i>>1]>>1)|((i&1)?(1<<(L-1)):0);
NTT(f,L,true),NTT(g,L,true);
for(int i=0;i<(1<<L);i++) f[i]=f[i]*g[i]%mod;
NTT(f,L,false);
poly ans;
for(int i=0;i<=2*n;i++) ans.a[i]=f[i-m+n]%mod;
// printf("m-n=%d-%d=%d\n",m,n,m-n);
// for(int i=0;i<=2*n;i++) printf("%d%c",a[i]," \n"[i==2*n]);
// for(int i=0;i<=2*n;i++) printf("%d%c",b.a[i]," \n"[i==2*n]);
// for(int i=0;i<=2*n;i++) printf("%d%c",ans.a[i]," \n"[i==2*n]);
return ans;
}
}v[30];
inline void solve()
{
n=read();ll M=lread(),V=M/n;m=M%n;
for(int i=1;i<=n;i++) w[i]=read()-V;
v[0].clear();poly ans;ans.a[n-m]=1;
for(int i=1;i<=n;i++) if(w[i]>=m-n&&w[i]<=m+n) v[0].a[w[i]-m+n]=1;
if(n&1) ans=ans*v[0];
for(int i=1;(1<<i)<=n;i++)
{
v[i]=v[i-1]*v[i-1];
if((n>>i)&1) ans=ans*v[i];
}
if(ans.a[n]) printf("Yes\n");
else printf("No\n");
}
int main()
{
int T=read();
while(T--) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 12796kb
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: 0
Accepted
time: 61ms
memory: 13064kb
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 No No No No No No Yes Yes Yes Yes Yes Yes Yes No No No No No No Yes No Yes No 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 Yes...
result:
ok 1314 token(s): yes count is 732, no count is 582
Test #3:
score: -100
Wrong Answer
time: 507ms
memory: 13216kb
input:
10000 4 1 0 0 0 0 4 1 0 0 0 1 4 1 0 0 0 2 4 1 0 0 0 3 4 1 0 0 0 4 4 1 0 0 1 0 4 1 0 0 1 1 4 1 0 0 1 2 4 1 0 0 1 3 4 1 0 0 1 4 4 1 0 0 2 0 4 1 0 0 2 1 4 1 0 0 2 2 4 1 0 0 2 3 4 1 0 0 2 4 4 1 0 0 3 0 4 1 0 0 3 1 4 1 0 0 3 2 4 1 0 0 3 3 4 1 0 0 3 4 4 1 0 0 4 0 4 1 0 0 4 1 4 1 0 0 4 2 4 1 0 0 4 3 4 1 0 ...
output:
No Yes No No No Yes Yes Yes Yes Yes No Yes No No No No Yes No No No No Yes No 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 Yes No No No Yes Yes Yes Yes Yes No Yes No No No No Yes No No No No Yes No No No No Yes No No No Yes Yes Yes Yes ...
result:
wrong answer expected YES, found NO [6270th token]