QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#103669#6347. XOR DeterminantSEM_PRESSAO_pedroteosousaWA 127ms3424kbC++232.1kb2023-05-07 07:06:192023-05-07 07:06:21

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-07 07:06:21]
  • 评测
  • 测评结果:WA
  • 用时:127ms
  • 内存:3424kb
  • [2023-05-07 07:06:19]
  • 提交

answer

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

using ll = long long;
#define int ll
#define all(v) v.begin(), v.end()
#define pb push_back

void dbg_out() { cerr << endl; }
template<typename H, typename... T>
void dbg_out(H h, T... t) { cerr << ' ' << h; dbg_out(t...); }
#define dbg(...) { cerr << #__VA_ARGS__ << ':'; dbg_out(__VA_ARGS__); }

template<int MOD> 
struct mint {
	int x;

	mint(): x(0) {}
	mint(int y): x(y<0?y%MOD+MOD : y%MOD) {}
	
	void operator+=(mint rhs) { x += rhs.x; if(x>=MOD) x-= MOD; }
	void operator-=(mint rhs) { x -= rhs.x; if(x<0) x+= MOD; }
	void operator*=(mint rhs) { x *= rhs.x; x %= MOD; }
	void operator/=(mint rhs) { *this *= rhs.inv(); }
	mint operator+(mint rhs) { mint res = *this; res += rhs; return res; }
	mint operator-(mint rhs) { mint res = *this; res -= rhs; return res; }
	mint operator*(mint rhs) { mint res = *this; res *= rhs; return res; }
	mint operator/(mint rhs) { mint res = *this; res /= rhs; return res; }

	mint inv() { assert(x != 0); return this->pow(MOD-2); }
	mint pow(int e) {
		mint res = 1;
		for(mint p=*this;e>0;e/=2,p*=p) if(e%2)
			res *= p;
		return res;
	}
};

using Z = mint<998244353>;

void solve() {
	int n; cin >> n;
	vector<int> b(n), c(n);
	for(auto &x: b) cin >> x;
	for(auto &x: c) cin >> x;

	if(n > 60) {
		cout << 0 << endl;
		return;
	}

	vector<vector<Z>> mat(n, vector<Z>(n));
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) {
		mat[i][j] = Z(b[i] xor c[j]);
	}

	int sign = 1;
	for(int j=0;j<n;j++) {
		for(int i=j+1;i<n;i++) {
			if(mat[j][j].x == 0) {
				sign *= -1;
				mat[j].swap(mat[i]);
			}
		}
		if(mat[j][j].x == 0) {
			cout << 0 << endl;
			return;
		}
		for(int i=j+1;i<n;i++) {
			Z f = mat[i][j] / mat[j][j];
			for(int k=j;k<n;k++) {
				mat[i][k] -= mat[j][k] * f;
			}
		}
	}

//	dbg("MATRIX", n);
//	for(int i=0;i<n;i++) for(int j=0;j<n;j++)
//		cerr << mat[i][j].x << " \n"[j==n-1];

	Z ans = sign;
	for(int i=0;i<n;i++) ans *= mat[i][i];
	cout << ans.x << endl;
}

signed main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int t; cin >> t;
	while(t--)
		solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3424kb

input:

3
2
2 5
4 1
1
1000000000000000001
987467354324283836
4
1 2 3 4
1 2 3 4

output:

21
214139910
998244129

result:

ok 3 number(s): "21 214139910 998244129"

Test #2:

score: 0
Accepted
time: 2ms
memory: 3392kb

input:

1
5
1 2 3 4 5
1 2 3 4 5

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: 0
Accepted
time: 4ms
memory: 3360kb

input:

100
10
1107560013855173757 966681903163989710 521892103913129269 1038348664970462356 604430971757857481 1106581500345020431 788162934600883665 124672524392773463 534904853987097709 784497626701360420
402515001559379490 846591944896429860 761680713769800085 722846292535048189 621369111578909792 49581...

output:

548320033
488137899
509538360
732652365
956551480
888843023
560651618
189658616
667887492
788885505
155196573
934158515
897579513
928218896
846866262
443345610
390799518
148725345
892245870
273938687
487734460
478338536
258981818
853512398
952636045
406224138
199504048
631337716
29490784
62730160
94...

result:

ok 100 numbers

Test #4:

score: 0
Accepted
time: 110ms
memory: 3372kb

input:

181
55
259826570151423127 58870406144128000 310271049587997524 401710073886773698 514286909385841735 162284846714225243 536074036455895273 265892726370365687 1083624247485293743 2294265759278634 1109697269509916767 119509764279027081 676809147172263541 685533985118893838 578164705093722225 749670267...

output:

250966714
189614849
870870263
628983732
439500925
167026357
880398758
988810735
911943102
1063939
834869831
322770187
318884496
313423629
256256099
557682540
821588970
365649865
728030647
227507483
54912370
697674469
17837535
608934788
198096034
862343012
611724164
461668994
190235391
3648045
303758...

result:

ok 181 numbers

Test #5:

score: 0
Accepted
time: 127ms
memory: 3388kb

input:

169
59
263131534273822231 721315260374372529 22596975172294779 587943029601145634 578406889381301720 1052976625790254378 1042479356926816953 62521207877861669 84439288007663497 104844738588741000 1114460585099051870 114694613171354451 737641966677819022 428614303859254465 736738606337870847 10270405...

output:

679833894
707359193
489328896
489331972
378698263
670232661
604105888
337180462
768492368
287273997
416687126
531928536
497729522
781926730
637316876
448456159
839190068
52762183
584682392
634497786
902597867
971239442
361789519
331227756
191954243
240205925
234462528
495375269
592860446
207834359
8...

result:

ok 169 numbers

Test #6:

score: 0
Accepted
time: 122ms
memory: 3420kb

input:

166
60
80154134565266370 488932265115032860 303835835035297206 575581085106658104 833807689536921183 187169890408130963 1048058980828122057 110567463708412924 327808012109170094 95218974667774735 433999115170249685 467678946339214050 609742608869014608 133569764370459119 776300965852048567 463747864...

output:

670693684
567395563
608098032
942216233
217410998
326969104
25422274
480790118
342481245
102562285
61647851
552914906
620545717
914965321
3734736
105108911
696719302
651957753
613434616
624957763
426547790
885982943
586546938
104962862
114875102
677394436
60012578
348000979
692703882
977900715
85838...

result:

ok 166 numbers

Test #7:

score: -100
Wrong Answer
time: 7ms
memory: 3424kb

input:

163
61
80980377743349794 78082725295428680 808378069808536832 277850281918593630 877981892336811364 898303075033883084 323880166130506137 525399171051596912 366242148391474277 120856593948882151 723420323440470677 764275661616196241 647981809066855810 259339928715802532 1105675893907201571 986085105...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

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