QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#66964#5169. 夹娃娃wind_cross0 30ms3488kbC++142.4kb2022-12-09 14:30:302022-12-09 14:30:33

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-09 14:30:33]
  • 评测
  • 测评结果:0
  • 用时:30ms
  • 内存:3488kb
  • [2022-12-09 14:30:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
inline char nc()
{
	static char buf[99999],*l,*r;
	return l==r&&(r=(l=buf)+fread(buf,1,99999,stdin),l==r)?EOF:*l++;
}
template <class code>inline code read(const code &a)
{
    code x=0;short w=0;char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    return w?-x:x;
}
void print(int x){
	if(x<0)putchar('-'),x=-x;
	if(x>=10)print(x/10);
	putchar(x%10+48);
}
const int g1=3,gi=332748118,mod=998244353,maxn=1024,inv=997269505;
int n,m,rev[maxn+5],a[maxn+5],dp[20][maxn+5],f[maxn+5],b[20][maxn+5],c[20][maxn+5],za[maxn+5],zb[maxn+5],qwq[maxn+5];
char s[maxn+5];
int add(int x){
    return x>=mod?x-mod:x;
}
int ksm(int x,int y){
    int now=1;
    while(y){
        if(y&1)now=1ll*now*x%mod;
        x=1ll*x*x%mod;
        y>>=1;
    }
    return now;
}
void NTT(int *g,bool op,int n){
  static ull f[maxn<<1],w[maxn<<1]={1};
  for(int i=0;i<n;i++)f[i]=g[rev[i]];
  for(int l=1;l<n;l<<=1){
    ull tG=ksm(op?g1:gi,(mod-1)/(l+l));
    for (int i=1;i<l;i++)w[i]=w[i-1]*tG%mod;
    for(int k=0;k<n;k+=l+l)
      for(int p=0;p<l;p++){
        int tt=w[p]*f[k|l|p]%mod;
        f[k|l|p]=f[k|p]+mod-tt;
        f[k|p]+=tt;
      }
  }if (!op){
    ull invn=ksm(n,mod-2);
    for(int i=0;i<n;++i)
      g[i]=f[i]%mod*invn%mod;
  }else for(int i=0;i<n;++i)g[i]=f[i]%mod;
}
void cl(int *a,int *b,int n){
    NTT(a,1,n);NTT(b,1,n);
    for(int i=0;i<n;i++)a[i]=1ll*a[i]*b[i]%mod;
    NTT(a,0,n);
}
signed main()
{
    int n=read(n),q=read(q),p=read(p);
    if(n>2)return 0;
    for(int i=0;i<maxn;i++)rev[i]=(rev[i>>1]>>1)|((i&1)?maxn>>1:0);
    for(int i=1;i<=n;i++){
        a[i]=read(a[i]);
        dp[i][0]=1;  
        for(int j=1;j<=a[i];j++){
            b[i][j]=read(b[i][j]),c[i][j]=read(c[i][j]);
            memset(f,0,sizeof(f));
            for(int k=0;k<=c[i][j]&&k*b[i][j]<maxn;k++)f[k*b[i][j]]=1;
            cl(dp[i],f,maxn);
        }
    }
    while(q--){
        int m,k;
        scanf("%s %d %d",s+1,&m,&k);
        memset(f,0,sizeof(f));
        f[0]=1;
        for(int i=1;i<=n;i++){
            memcpy(qwq,dp[i],sizeof(dp[i]));
            if(s[i]=='1')for(int j=0;j<k;j++)qwq[j]=0;
            cl(f,qwq,maxn);
        }
        int ans=0;
        for(int j=0;j<=m;j++)ans=add(ans+f[j]);
        printf("%d\n",ans);
    }
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 30ms
memory: 3488kb

input:

1 521 998244353
39 520 520 11 22 414 8 95 18 229 356 26 407 316 10 24 26 19 61 11 130 482 476 420 15 192 193 208 24 19 233 494 217 275 294 26 28 439 20 272 277 28 198 5 335 22 8 28 17 154 78 6 13 175 17 2 5 477 256 200 4 1 36 427 371 439 23 10 65 426 25 24 27 121 29 28 13 12 453
0 520 1
1 519 1
1 51...

output:

328525095
629881229
931206168
780390505
83727337
83950275
535756280
536146972
837643593
837571028
837085146
988388572
291444907
291279106
441978949
592083409
743778257
197315462
46199217
349222226
649161490
498676433
801469115
103038448
104413597
103541382
253683312
706912959
707137037
706053050
108...

result:

wrong answer 1st lines differ - expected: '38813347', found: '328525095'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Wrong Answer

Test #9:

score: 0
Wrong Answer
time: 1ms
memory: 3432kb

input:

15 52099 998244353
1 9 3
1 9 4
1 9 2
1 8 10
1 4 4
1 3 1
1 2 5
1 4 9
1 1 4
1 9 4
1 7 6
1 1 6
1 2 5
1 5 2
1 3 5
101000000001010 516 1
010001001010101 520 2
000000101000001 519 2
101011111100011 518 1
010110001000111 520 2
000110111100111 516 1
000100101001011 519 3
000111001010011 518 1
00001110010111...

output:


result:

wrong answer 1st lines differ - expected: '993379058', found: ''

Subtask #5:

score: 0
Skipped

Dependency #3:

0%

Subtask #6:

score: 0
Skipped

Dependency #4:

0%

Subtask #7:

score: 0
Skipped

Dependency #6:

0%