QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#66593#5169. 夹娃娃Minion0 68ms2388kbC++232.6kb2022-12-09 09:22:132022-12-09 09:22:15

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:22:15]
  • 评测
  • 测评结果:0
  • 用时:68ms
  • 内存:2388kb
  • [2022-12-09 09:22:13]
  • 提交

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 = 520,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: 68ms
memory: 2388kb

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:

506655047
232445471
360191576
490749405
281755948
74634229
123730517
675262253
67419314
981844432
544318130
845448878
288541139
814827747
146004109
992948424
182743048
202035447
746111785
665706601
764634912
362507833
410240655
55097333
717262104
956396563
971393461
934915326
857094328
914900394
430...

result:

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

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%