QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#66589#5169. 夹娃娃10circle0 2543ms34844kbC++142.9kb2022-12-09 09:16:582022-12-09 09:17:01

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:17:01]
  • 评测
  • 测评结果:0
  • 用时:2543ms
  • 内存:34844kb
  • [2022-12-09 09:16:58]
  • 提交

answer


// 哈哈,不认识“娃”这个字了。

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vint;

int read() {
	int a = 0, b = 0; char c = getchar();
	while (c < '0' || c > '9') b ^= (c == '-'), c = getchar();
	while (c >= '0' && c <= '9') a = a * 10 - 48 + c, c = getchar();
	return b ? -a : a;
}

const int N = 15, V = 1024;
const int mod = 998244353, G = 3, iG = 332748118;
int n, q, f[N][V], vf[N][521][V];
void Add(int &a, int b) { if ((a += b) >= mod) a -= mod; }
void Sub(int &a, int b) { if ((a -= b) < 0) a += mod; }
int add(int a, int b) { return (a + b >= mod) ? a + b - mod : a + b; }
int sub(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }
void Fav(int &a, int b, int c) { a = (a + (ll)b * c) % mod; }
void Mul(int &a, int b) { a = (ll)a * b % mod; }
int mul(int a, int b) { return (ll)a * b % mod; }
int pw(ll a, int k) { ll s = 1; while (k) { if (k & 1) s = s * a % mod; a = a * a % mod; k >>= 1; } return s; }

int rv[V];

void init() {
	for (int i = 1; i < V; ++i) rv[i] = (rv[i >> 1] >> 1) | ((i & 1) ? (V >> 1) : 0);
}

void NTT(int f[], int ag = 1) {
	for (int i = 0; i < V; ++i) if (i < rv[i]) swap(f[i], f[rv[i]]);
	for (int k = 2; k <= V; k <<= 1) {
		int rk = k >> 1, w = pw(G, (mod - 1) / k);
		for (int i = 0; i < V; i += k) {
			int r = 1;
			for (int j = i; j < i + rk; ++j) {
				int g = mul(f[j + rk], r);
				f[j + rk] = sub(f[j], g);
				Add(f[j], g);
				
				Mul(r, w);
			}
		}
	}
	if (!ag) {
		int iV = pw(V, mod - 2);
		reverse(f + 1, f + V);
		for (int i = 0; i < V; ++i) Mul(f[i], iV);
	}
}

int main() {
//	freopen("a.in", "r", stdin);
//	freopen("a.out", "w", stdout);
	init();
	n = read(), q = read();
	read();
	// mod = read();
	for (int i = 0; i < n; ++i) {
		int a = read();
		f[i][0] = 1;
		for (int r = 0; r < a; ++r) {
			int b = read(), c = read();
			static int g[V];
			for (int k = 0; k < V; ++k) g[k] = add(f[i][k], (k >= b ? g[k - b] : 0));
			for (int k = 0; k < V; ++k) f[i][k] = sub(g[k], (k >= b * (c + 1) ? g[k - b * (c + 1)] : 0));
		}
		memcpy(vf[i][0], f[i], V << 2);
		for (int k = 0; k < 520; ++k) {
			memcpy(vf[i][k + 1] + k + 1, vf[i][k] + k + 1, (V - k - 1) << 2);
			NTT(vf[i][k]);
		}
		NTT(vf[i][520]);
	}
	for (int i = 0; i < q; ++i) {
		char s[20];
		int m, k, v = 0;
		scanf("%s%d%d", s, &m, &k);
		for (int j = 0; j < n; ++j) if (s[j] == '1') v |= 1 << j;
		if (k * __builtin_popcount(v) > m) {
			cout << 0 << '\n';
			continue;
		}
		static int g[V];
		for (int i = 0; i < V; ++i) g[i] = 1;
		for (int j = 0; j < n; ++j) {
			if ((v >> j) & 1) {
				for (int i = 0; i < V; ++i) Mul(g[i], vf[j][k][i]);
			} else {
				for (int i = 0; i < V; ++i) Mul(g[i], vf[j][0][i]);
			}
		}
		NTT(g, 0);
		int ans = 0;
		for (int j = 0; j <= m; ++j) Add(ans, g[j]);
		cout << ans << '\n';
	}
	return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 3
Accepted
time: 25ms
memory: 5640kb

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
922143638
98254957
38813343
922143633
38813338
98254946
922143620
98254933
922143604
38813302
38813288
922143562
38813247
38813220
38813188
38813150
98254715
38813047
922143273
98254516
38812814
922142999
98254191
922142723
38812257
38812058
98253436
922141847
38811240
922141173
38810463
38...

result:

ok 521 lines

Test #2:

score: -3
Wrong Answer
time: 68ms
memory: 7632kb

input:

2 1561 998244353
151 520 520 511 30 121 396 25 16 113 11 6 175 242 20 8 5 61 13 518 447 404 8 220 177 4 19 18 15 70 233 9 14 26 512 17 9 9 19 30 8 495 20 13 27 277 22 396 14 4 29 345 442 19 25 14 5 16 295 19 65 134 10 10 296 245 6 7 30 253 15 187 26 482 454 28 414 170 404 11 27 27 25 13 509 1 5 291 ...

output:

826958811
220330025
773649081
77239482
342529921
649392268
260934018
516327590
159905754
352812445
764777553
292989988
464875723
262288880
253715457
80160819
183701848
914312466
323871165
187760818
846432324
989647986
475587885
957850573
454669035
246794404
350187652
505033303
816995137
914992687
64...

result:

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

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: 10
Accepted
time: 2489ms
memory: 34780kb

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:

993379058
496689529
866368587
797687294
481245176
481245176
39022588
269889529
552778235
769822588
331666941
99789529
903956470
112750588
756797435
519045176
870912000
361582588
594280447
494747647
597778941
178845176
435456000
493445999
461733882
308912117
271186941
496689529
919511294
85533882
894...

result:

ok 52099 lines

Test #10:

score: -10
Wrong Answer
time: 2543ms
memory: 34844kb

input:

15 52099 998244353
1 444 1
1 184 2
1 427 1
1 23 1
1 513 2
1 413 4
1 304 2
1 214 5
1 108 2
1 304 1
1 283 5
1 465 1
1 277 1
1 57 2
1 160 4
111010111100101 520 25
010010011100110 520 3
010000011011000 519 36
110011011100110 516 21
010110001101101 516 42
100001101000111 520 31
110001100010001 519 10
110...

output:

9391
46869
210615
15491
0
62527
140353
99842
29164
111869
13972
15578
39253
0
0
0
0
84099
8796
49380
0
26221
197822
0
37508
52656
0
0
35046
49484
10889
0
140636
3884
0
0
29233
175494
0
13201
0
63067
0
7019
24530
17530
43781
58140
0
0
0
15631
70048
8195
23455
117012
197821
34933
37243
31481
0
0
7806
...

result:

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

Subtask #5:

score: 0
Skipped

Dependency #3:

0%

Subtask #6:

score: 0
Skipped

Dependency #4:

0%

Subtask #7:

score: 0
Skipped

Dependency #6:

0%