QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#103607#6352. SPPPSPSS.SEM_PRESSAO_pedroteosousa#WA 0ms3432kbC++232.1kb2023-05-07 04:10:212023-05-07 04:10:22

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 04:10:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3432kb
  • [2023-05-07 04:10:21]
  • 提交

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 > 64) {
		cout << 0 << endl;
	}

	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: 0
Wrong Answer
time: 0ms
memory: 3432kb

input:

3
1 2 3

output:

1
0
0

result:

wrong answer Token "1" doesn't correspond to pattern "[PS]{0,1000001}."