QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#297283#5829. 马戏团里你最忙FISHER_0 1ms5980kbC++142.0kb2024-01-04 09:24:412024-01-04 09:24:41

Judging History

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

  • [2024-01-04 09:24:41]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:5980kb
  • [2024-01-04 09:24:41]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
inline int Mod(int x) { return x + ((x >> 31) & mod); }
inline int add(int x, int y) { return Mod(x + y - mod); }
inline int sub(int x, int y) { return Mod(x - y); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
int qpow(int a, int b) {
	if (!b) return 1;
	int t = qpow(a, b >> 1);
	t = mul(t, t);
	if (b & 1) return mul(t, a);
	return t;
}
const int maxn = 17;
int n, p, pp, K, x0;
int c[1 << maxn];
int f[25][1 << maxn], g[25][1 << maxn];
void fwtOr(int v[], int len, bool tp) {
	for (int i = 1; i < len; i <<= 1)
		for (int j = 0; j < len; j += i << 1)
			for (int k = 0; k < i; k++) {
				if (tp) v[i + j + k] = sub(v[i + j + k], v[j + k]);
				else v[i + j + k] = add(v[i + j + k], v[j + k]);
			}
}
void fwtAnd(int v[], int len, bool tp) {
	for (int i = 1; i < len; i <<= 1)
		for (int j = 0; j < len; j += i << 1)
			for (int k = 0; k < i; k++) {
				if (tp) v[j + k] = sub(v[j + k], v[i + j + k]);
				else v[j + k] = add(v[j + k], v[i + j + k]);
			}
}
int tra[1 << maxn], tro[1 << maxn];
int t1[1 << maxn], t2[1 << maxn];
void tr(const int fr[], int to[], int len) {
	memcpy(t1, fr, sizeof(t1));
	fwtOr(t1, len, 0);
	for (int s = 0; s < len; s++) to[s] = mul(mul(t1[s], tro[s]), p);
	fwtOr(to, len, 1);
	memcpy(t1, fr, sizeof(t1));
	fwtAnd(t1, len, 0);
	for (int s = 0; s < len; s++) t2[s] = mul(mul(t1[s], tra[s]), pp);
	fwtAnd(t2, len, 1);
	for (int s = 0; s < len; s++) to[s] = add(to[s], t2[s]);
}
int main() {
	freopen("test.in", "r", stdin);
	scanf("%d%d%d%d", &n, &p, &K, &x0), pp = sub(1, p);
	int S = 1 << n;
	int inv = qpow(S, mod - 2);
	for (int s = 0; s < S; s++) {
		scanf("%d", &c[s]);
		tra[s] = tro[s] = inv;
	}
	fwtAnd(tra, S, 0), fwtOr(tro, S, 0);
	g[0][x0] = 1;
	for (int i = 1; i <= K; i++) {
		tr(g[i - 1], g[i], S);
		tr(f[i - 1], f[i], S);
		for (int s = 0; s < S; s++) f[i][s] = add(f[i][s], mul(g[i][s], c[s]));
	}
	for (int s = 0; s < S; s++) printf("%d ", f[K][s]);
}

詳細信息

Test #1:

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

input:

17 203635058 20 45197
630927925 367691872 854861811 935381440 972493717 952218952 40627765 901726383 333182690 814058886 114559515 857808755 180823985 448291128 904629758 587362495 553139819 808271094 537555635 876810522 460868754 965863351 816253267 677756972 587551773 48482825 12382358 781942390 2...

output:

0 

result:

wrong answer 1st numbers differ - expected: '196898572', found: '0'

Test #2:

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

input:

17 55303977 20 32265
494363203 155538370 630883878 512423276 148363202 832624635 801640865 903488980 811127763 249184672 605607782 287932872 764562597 387167720 508436523 263243837 25444512 71537379 602424523 577977303 207298251 640159465 917833936 352635217 315477193 937365223 740930608 774925120 2...

output:

0 

result:

wrong answer 1st numbers differ - expected: '289704320', found: '0'

Test #3:

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

input:

17 126833065 1000 123430
911917407 121906013 929903588 323429234 139121451 3203442 65035849 409625525 525882288 532577435 971826327 904691827 481756384 47231489 346006246 274441242 584793873 841520735 543444701 644939661 885202827 142653644 180313583 548253835 847010044 216554243 124989074 619408231...

output:

0 

result:

wrong answer 1st numbers differ - expected: '134631343', found: '0'

Test #4:

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

input:

17 621627241 1000 37306
874709248 739473737 912060934 158833941 971188630 744039312 327912594 702720054 185196283 745584702 903434215 484148979 176610819 222341600 961711994 877263458 352785155 12121832 920590333 736755672 428869475 220835314 277186463 787049344 504919397 134827356 59724693 78120026...

output:

0 

result:

wrong answer 1st numbers differ - expected: '287767112', found: '0'

Test #5:

score: 0
Wrong Answer
time: 0ms
memory: 5920kb

input:

1 836026557 1000000000 1
89073685 44729188

output:

0 

result:

wrong answer 1st numbers differ - expected: '936822371', found: '0'

Test #6:

score: 0
Wrong Answer
time: 0ms
memory: 5916kb

input:

8 729700268 1000000000 44
415083631 759858310 528846926 698375322 811429471 668487195 443858087 600445292 190489246 123673503 530450450 76731586 197623863 866555166 743879064 141858132 642913199 103864508 528442021 931490458 969629325 724240247 392146627 32067149 882745389 980834475 140464044 516308...

output:

0 

result:

wrong answer 1st numbers differ - expected: '830023741', found: '0'

Test #7:

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

input:

17 499122177 1000000000 101368
879449681 64374006 2136324 179144921 432405367 443552363 403139437 39083535 353339709 78321779 538844553 158621708 576996457 284607049 353163162 754891442 765538773 579712088 200974213 4059721 644110071 271278034 94792222 726122290 905812908 137101325 873585214 5466611...

output:

0 

result:

wrong answer 1st numbers differ - expected: '76712311', found: '0'

Test #8:

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

input:

17 73054278 1000000000 103328
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

0 

result:

wrong answer 1st numbers differ - expected: '307343988', found: '0'

Test #9:

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

input:

16 544826057 1000000000 58181
127333103 438073137 374751329 498443816 423416409 925764567 46036736 110186961 233535448 830000756 676728537 294866428 430284448 424338238 337810871 397978 916371232 246055490 114266106 174763813 816533383 346479346 358334243 10507119 464920585 275232506 870081558 38720...

output:

0 

result:

wrong answer 1st numbers differ - expected: '770450440', found: '0'

Test #10:

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

input:

17 596529770 1000000000 121733
359584182 80170529 721719197 271156012 552773637 882685657 619483754 39827609 20656366 82444398 478178854 625533821 736267120 37211948 503896746 770716690 554769769 575127167 638367404 541442475 219866908 428643659 649491821 417360007 540021485 514124438 754101213 3068...

output:

0 

result:

wrong answer 1st numbers differ - expected: '421614534', found: '0'