QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#340983#1004. 快速 XOR 卷积KevinLikesCoding#0 0ms0kbC++142.1kb2024-02-29 14:47:032024-02-29 14:47:04

Judging History

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

  • [2024-02-29 14:47:04]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-02-29 14:47:03]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<=(m);i++)
#define ROF(i,n,m) for(int i=(n);i>=(m);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define SZ(v) v.size()
#define pb push_back
template < typename A , typename B>
inline bool chmax(A &x, B y) { return (x < y ? (x = y, true) : false); }
template < typename A , typename B>
inline bool chmin(A &x, B y) { return (x > y ? (x = y, true) : false); }
const int N = 1e6 + 5;
const int P = 998244353;
int n, s, a[N], b[N];
int add(int x, int y) { return (x + y < P ? x + y : x + y - P); }
void Add(int &x, int y) { x = (x + y < P ? x + y : x + y - P);}
int sub(int x, int y) { return (x - y < 0 ? x - y + P : x - y); }
void Sub(int &x, int y) { x = (x - y < 0 ? x - y + P : x - y); }
int mul(int x, int y) { return (1ll * x * y) % P; }
void Mul(int &x, int y) { x = (1ll * x * y) % P; }
int fp(int x, int y) { int res = 1; for(; y; y >>= 1) { if(y & 1) Mul(res, x); Mul(x, x); } return res; }
int inv(int x) { return fp(x, P - 2); }
void OR(int *a, int opt) {
	for(int i = 1; i < s; i <<= 1) 
		for(int j = 0; j < s; j += (i << 1)) 
			for(int k = 0; k < i; k++) 
				Add(a[j + k + i], (opt == 1 ? a[j + k] : P - a[j + k]));
}
void AND(int *a, int opt) {
	for(int i = 1; i < s; i <<= 1) 
		for(int j = 0; j < s; j += (i << 1)) 
			for(int k = 0; k < i; k++) 
				Add(a[j + k], (opt == 1 ? a[j + k + i] : P - a[j + k + i]));
}
void XOR(int *a, int opt) {
	for(int i = 1; i < s; i <<= 1) 
		for(int j = 0; j < s; j += (i << 1)) 
			for(int k = 0; k < i; k++) {
				int x = a[j + k];
				int y = a[j + k + i];
				a[j + k] = add(x, y);
				a[j + k + i] = sub(x, y);
				if(opt == -1) {
					Mul(a[j + k], inv(2));
					Mul(a[j + k + i], inv(2));
				}
			}
}
void solve() {
	cin >> n;
	s = 1 << n;
	REP(i, s) cin >> a[i];
	REP(i, s) cin >> b[i];
	XOR(a, 1);
	XOR(b, 1);
	REP(i, s) Mul(a[i], b[i]);
	XOR(a, -1);
	REP(i, s) cout << a[i] << " ";
}
int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

17
12971 87517 21493 129172 55449 49056 84226 60548 107778 94553 94762 35834 62355 103942 1589 56049 64049 52657 13647 458 32499 10726 32746 16451 97495 80824 45233 13117 37142 117070 44795 1503 39107 17458 113346 77453 67829 98425 107567 67863 109865 88834 54880 108007 112287 6219 121301 115460 114...

output:


result:


Test #2:

score: 0
Time Limit Exceeded

input:

17
60681 43091 80828 84253 116262 125738 38458 47302 7816 48510 1739 126330 56987 29628 19300 58590 58805 84834 37607 85108 42824 104724 53232 73419 88929 120013 17556 126592 77200 108866 80463 19973 54540 75236 4447 34141 55852 83199 35626 15859 34602 87863 95828 24276 46221 28871 102512 130109 952...

output:


result:


Test #3:

score: 0
Time Limit Exceeded

input:

17
80123 95971 37761 56275 108050 26373 101243 111039 61518 53462 50199 89421 4407 130890 86035 19719 69203 123363 107339 118003 91310 73762 91912 103483 104511 19917 119315 124430 97370 54405 39124 104828 123881 85074 38405 69557 19382 128321 55962 38389 41105 43537 128932 29395 120164 27652 121841...

output:


result:


Test #4:

score: 0
Time Limit Exceeded

input:

17
108939 64572 52175 61053 115827 90090 90712 71972 57340 96612 130277 95021 31140 116050 43691 43802 52242 32913 63231 50123 11700 84047 77730 7205 3920 97931 75125 22985 7819 85108 121546 118894 104930 129850 8015 29275 103196 124506 38732 76256 59318 70181 19572 49661 38361 304 125641 52720 1057...

output:


result:


Test #5:

score: 0
Time Limit Exceeded

input:

17
31774 67725 65380 69381 126096 130251 17026 66144 86636 1003 38183 44160 72510 58745 102958 63604 117646 67739 41196 78052 55940 36095 12434 123628 37896 49214 34244 75942 21320 63455 66385 97929 104259 92206 78015 38177 97295 89357 41766 72056 46879 97478 100720 15389 12924 92934 47851 42725 853...

output:


result:


Test #6:

score: 0
Time Limit Exceeded

input:

17
128832 40041 41368 104210 74000 120943 91735 94779 127869 68612 110143 104621 92991 72979 122777 39422 128799 14898 105541 57692 101463 66816 115636 109294 83181 7187 79264 1928 102559 76557 23190 105321 63523 17794 6806 50895 77097 106912 45722 111347 6619 65559 109836 115427 4879 88308 87890 98...

output:


result:


Test #7:

score: 0
Time Limit Exceeded

input:

17
72783 6091 19840 63551 18810 111065 21841 38393 123524 57925 14635 31627 86050 58432 43867 5202 47233 106182 34732 90077 9315 127975 54930 104606 79356 37755 73553 112255 98273 54764 5292 60613 23374 113347 4995 114800 58352 85709 81020 19773 102919 31355 84369 103097 2001 37268 109920 95173 9404...

output:


result:


Test #8:

score: 0
Time Limit Exceeded

input:

17
46309 89219 114374 41892 49238 10478 107055 98444 47093 50979 97846 74576 92885 79209 118666 19635 3460 58696 23156 5848 12493 76587 64564 6789 3575 79063 101453 5388 61638 71697 19932 68093 48232 56859 121208 46261 6897 87013 9732 64635 66395 107851 392 33439 85489 6382 4671 9866 56412 20250 822...

output:


result:


Test #9:

score: 0
Time Limit Exceeded

input:

17
27754 86939 42679 63610 33946 125278 110623 12553 116511 44588 60498 37304 125848 56270 76687 65142 50934 72435 97308 50362 110254 39337 53832 77230 2666 119442 61718 104884 64126 39964 59510 52802 98741 98026 6032 2857 64718 69433 75089 125294 122386 19656 126033 63680 72188 36218 130484 49102 9...

output:


result:


Test #10:

score: 0
Time Limit Exceeded

input:

17
92675 49618 93296 44550 86315 1135 84572 125202 81170 10398 76335 103794 63635 74494 58874 87903 52174 110193 87955 33432 22146 73241 83004 52072 84882 21505 33617 5880 81903 31364 98529 93950 74497 44469 15897 59590 95509 71 125003 14795 122158 130832 80779 17994 110212 106866 80913 40081 106507...

output:


result: