QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#240306 | #6347. XOR Determinant | jzh# | WA | 1ms | 3664kb | C++20 | 1.5kb | 2023-11-05 14:26:58 | 2023-11-05 14:26:59 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll Ha = 998244353;
int n;
ll b[5006], c[5005];
ll ksm(ll x, int k) {
ll ret = 1;
for (; k; k >>= 1, x = x * x % Ha)
if (k & 1) ret = ret * x % Ha;
return ret;
}
void solve() {
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%lld", &b[i]);
for (int i = 0; i < n; i++) scanf("%lld", &c[i]);
if (n > 200) {
puts("0");
return;
}
vector<vector<ll>> a(n, vector<ll>(n));
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) a[i][j] = b[i] ^ c[j];
}
ll det = 1;
for (int i = 0; i < n; i++) {
int k = i;
for (int j = i + 1; j < n; j++)
if (a[j][i] > a[k][i]) k = j;
if (a[k][i] == 0) {
det = 0;
break;
}
swap(a[i], a[k]);
if (i != k) det = (-det % Ha + Ha) % Ha;
det = det * a[i][i] % Ha;
for (int j = i + 1; j < n; j++) {
a[i][j] = a[i][j] * ksm(a[i][i], Ha - 2) % Ha;
}
for (int j = 0; j < n; j++) {
if (j != i && a[j][i] != 0) {
for (int k = i + 1; k < n; k++) {
a[j][k] -= a[i][k] * a[j][i] % Ha;
a[j][k] = (a[j][k] % Ha + Ha) % Ha;
}
}
}
}
printf("%lld\n", det);
}
int main() {
int ttt;
scanf("%d", &ttt);
while (ttt--) {
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3580kb
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: 0ms
memory: 3580kb
input:
1 5 1 2 3 4 5 1 2 3 4 5
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3664kb
input:
100 10 1107560013855173757 966681903163989710 521892103913129269 1038348664970462356 604430971757857481 1106581500345020431 788162934600883665 124672524392773463 534904853987097709 784497626701360420 402515001559379490 846591944896429860 761680713769800085 722846292535048189 621369111578909792 49581...
output:
486054876 101739322 934932307 374368480 953482340 937767059 120485999 657524919 899419656 885015737 672664609 774774337 803072862 328758519 327005299 750331483 358054736 264759964 679584279 276958561 31137430 36838296 656022871 558248159 668933537 574410087 927294816 993257945 482263052 800615085 11...
result:
wrong answer 1st numbers differ - expected: '548320033', found: '486054876'