QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#66591#5169. 夹娃娃Minion0 67ms2284kbC++232.5kb2022-12-09 09:20:242022-12-09 09:20:24

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 09:20:24]
  • 评测
  • 测评结果:0
  • 用时:67ms
  • 内存:2284kb
  • [2022-12-09 09:20:24]
  • 提交

answer

#include<cstdio>
#define fo(i,x,y) for(int i = x;i <= y;++i)
#define fd(i,x,y) for(int i = x;i >= y;--i)
#define _is 1048576 * 3
#define _os 1048576
#define gc() ib[++bi]
#define pc(ch) ob[++bo] = ch
#define p 998244353
#define N 2048
#define add(x,y) (x >= p - y ? x + y - p : x + y)
#define sub(x,y) (x < y ? x - y + p : x - y)
using namespace std;
char ib[_is],ob[_os];int bi = -1,bo = -1;
int rd()
{
	int x = 0;char ch = gc();
	while(ch < 48 || ch > 57) ch = gc();
	while(ch >= 48 && ch <= 57) x = x * 10 + ch - 48,ch = gc();return x;
}
void gs(char *s)
{
	int l = -1;char ch = gc();
	while(ch != 48 && ch != 49) ch = gc();
	while(ch == 48 || ch == 49) s[++l] = ch,ch = gc();
	s[++l] = 0;
}
void pr(int x)
{
	char ch[20];int w = -1;
	if(x == 0) ch[++w] = 48;
	while(x) ch[++w] = x % 10 + 48,x /= 10;
	fd(i,w,0) pc(ch[i]);pc('\n');
}
int n,q,P,a[20][N],m = N,k;
char s[20];
int f[N],g[N],w[N + 1],iN;
void inc(int &x,int y) {x = x + y >= p ? x + y - p : x + y;}
int ksm(int x,int y)
{
	int res = 1;
	for(;y;y >>= 1,x = 1ll * x * x % p) if(y & 1) res = 1ll * res * x % p;
	return res;
}
void pre()
{
	int lg = 11;
	w[0] = 1,w[1ll << lg] = ksm(3,p - 1 >> lg + 2);
	fd(i,lg,1) w[1ll << i - 1] = 1ll * w[1ll << i] * w[1ll << i] % p;
	fo(i,1,N - 1) w[i] = 1ll * w[i & i - 1] * w[i & -i] % p;
}
void DIF(int *a)
{
	for(int l = N >> 1;l;l >>= 1) for(int i = 0,k = 0;i < N;i += l << 1,++k) fo(j,0,l - 1)
	{
		int x = a[i + j],y = 1ll * a[i + j + l] * w[k] % p;
		a[i + j] = add(x,y),a[i + j + l] = sub(x,y);
	}
}
void DIT(int *a)
{
	for(int l = 1;l < N;l <<= 1) for(int i = 0,k = 0;i < N;i += (l << 1),++k) fo(j,0,l - 1)
	{
		int x = a[i + j],y = a[i + j + l];
		a[i + j] = add(x,y),a[i + j + l] = 1ll * sub(x,y) * w[k] % p;
	}
	fo(i,1,N - 1 >> 1) a[i] ^= a[N - i] ^= a[i] ^= a[N - i];
	fo(i,0,N - 1) a[i] = 1ll * a[i] * iN % p;
}
void M(int *f)
{
	DIF(f),DIF(g);
	fo(i,0,2047) f[i] = 1ll * f[i] * g[i] % p;
	DIT(f);
	fo(i,m + 1,2047) f[i] = 0;
}
int main()
{
	fread(ib,1,_is,stdin);
	n = rd(),q = rd(),P = rd(),iN = ksm(N,p - 2);
	pre();
	fo(i,1,n)
	{
		int m = rd();
		a[i][0] = 1;
		while(m--)
		{
			int b = rd(),c = rd();
			fo(j,0,2047) g[j] = 0;
			fo(j,0,c) g[j * b] = 1;
			M(a[i]);
		}
	}
	while(q--)
	{
		gs(s + 1),m = rd(),k = rd();
		fo(i,0,2047) f[i] = 0;
		f[0] = 1;
		fo(i,1,n)
		{
			int l = 0;
			if(s[i] == 49) l = k;
			fo(j,0,2047) g[j] = 0;
			fo(j,l,m) g[j] = a[i][j];
			M(f);
		}
		int ans = 0;
		fo(i,0,m) inc(ans,f[i]);
		pr(ans);
	}
	fwrite(ob,1,bo + 1,stdout);
	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: 67ms
memory: 2284kb

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:

513451036
629749291
892606938
181509735
148161691
962087733
578342423
47370032
752868619
420334133
446412022
512884379
776870015
149854240
264494658
151800963
266383924
344353327
100423428
462057024
942496584
698418202
348529491
927021419
975491572
448257903
802123384
538581528
974467988
832335080
6...

result:

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

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Time Limit Exceeded

Test #9:

score: 0
Time Limit Exceeded

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:


Subtask #5:

score: 0
Skipped

Dependency #3:

0%

Subtask #6:

score: 0
Skipped

Dependency #4:

0%

Subtask #7:

score: 0
Skipped

Dependency #6:

0%