QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#66782#5169. 夹娃娃Minion0 2538ms3844kbC++233.1kb2022-12-09 11:50:202022-12-09 11:50:21

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 11:50:21]
  • 评测
  • 测评结果:0
  • 用时:2538ms
  • 内存:3844kb
  • [2022-12-09 11:50:20]
  • 提交

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 1024
#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 min(int x,int y) {return x < y ? 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 = 10;
	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;
}
int t[530];
void M(int *f)
{
	fo(i,512,520) t[i] = 0;
	fo(i,0,8) fo(j,512,520) t[i + j] = (t[i + j] + 1ll * f[i] * g[j] + 1ll * g[i] * f[j]) % p;
	fo(i,512,520) f[i] = g[i] = 0;
	DIF(f),DIF(g);
	fo(i,0,N - 1) f[i] = 1ll * f[i] * g[i] % p;
	DIT(f);
	fo(i,m + 1,N - 1) f[i] = 0;	
	fo(i,512,m) inc(f[i],t[i]);
}
int main()
{
	fread(ib,1,_is,stdin);
	n = rd(),q = rd(),P = rd(),iN = ksm(N,p - 2);
	pre();
	int A = 0;
	fo(i,1,n)
	{
		int m = rd();
		if(m > A) A = m;
		a[i][0] = 1;
		while(m--)
		{
			int b = rd(),c = rd();
			fo(j,0,N - 1) g[j] = 0;
			fo(j,0,min(c,520 / b)) g[j * b] = 1;
			M(a[i]);
		}
	}
	while(q--)
	{
		gs(s + 1),m = rd(),k = rd();
		bool bz = 0;
		fo(i,0,m) f[i] = 0;
		f[0] = 1;
		fo(i,1,n)
		{
			int l = 0;
			if(s[i] == 49) l = k;
			if(bz == 0)
			{
				fo(j,l,m) f[j] = a[i][j];
				bz = 1;continue;
			}
			fo(j,0,N - 1) g[j] = 0;
			fo(j,l,m) g[j] = a[i][j];
			if(m <= 200 || A == 1)
			{
				fo(j,0,m) t[j] = f[j],f[j] = 0;
				fo(j,0,m)
				{
					if(g[j] == 0) continue;
					fo(j1,0,m - j) f[j + j1] = (f[j + j1] + 1ll * g[j] * t[j1]) % p;
				}
			}
			else M(f);
		}
		int ans = 0;
		fo(i,0,m) inc(ans,f[i]);
		pr(ans);
	}
	fwrite(ob,1,bo + 1,stdout);
	return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 1544kb

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:

38813347
922143639
98254958
38813344
922143634
38813339
98254947
922143621
98254934
922143605
38813303
38813289
922143563
38813248
38813221
38813189
38813151
98254716
38813048
922143274
98254517
38812815
922143000
98254192
922142724
38812258
38812059
98253437
922141848
38811241
922141174
38810464
38...

result:

wrong answer 2nd lines differ - expected: '922143638', found: '922143639'

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: 2538ms
memory: 3844kb

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:

991757293
496689529
866368587
730834941
481245176
481245176
39022588
269889529
552778235
360933882
442222588
465800823
903956470
483082235
756797435
359312117
162971647
814858235
126877694
992411647
797038588
178845176
580608000
325179881
461733882
308912117
271186941
496689529
893266941
114045176
4...

result:

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

Subtask #5:

score: 0
Skipped

Dependency #3:

0%

Subtask #6:

score: 0
Skipped

Dependency #4:

0%

Subtask #7:

score: 0
Skipped

Dependency #6:

0%