QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#548239 | #6347. XOR Determinant | BFSDFS123# | WA | 2ms | 4364kb | C++14 | 1.1kb | 2024-09-05 16:33:16 | 2024-09-05 16:33:16 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
const int Mod=998244353;
const int Maxn=5010;
int qpow(int a,int b=Mod-2)
{
int res=1;
while(b)
{
if(b&1)
{
res=res*a%Mod;
}
a=a*a%Mod;
b>>=1;
}
return res;
}
int a[Maxn],b[Maxn];
int n;
int C[Maxn][Maxn];
int work()
{
int ans=1;
for(int i=1;i<=n;i++)
{
for(int j=i;j<=n;j++)
{
if(C[j][i])
{
if(j!=i) ans=-ans;
swap(C[i],C[j]);break;
}
}
if(!C[i][i]) return 0;
int inv=qpow(C[i][i]);
for(int j=i+1;j<=n;j++)
{
int t=inv*C[j][i]%Mod;
for(int k=i;k<=n;k++)
{
C[j][k]=(C[j][k]-t*C[i][k])%Mod;
}
}
ans=ans*C[i][i]%Mod;
}
return (ans%Mod+Mod)%Mod;
}
void solve()
{
scanf("%lld",&n);
for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
for(int i=1;i<=n;i++) scanf("%lld",&b[i]);
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
C[i][j]=a[i]^b[j];
if(n>61) puts("0");
else printf("%lld\n",work());
}
signed main()
{
int T;
scanf("%lld",&T);
while(T--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4004kb
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: 4076kb
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: 2ms
memory: 4364kb
input:
100 10 1107560013855173757 966681903163989710 521892103913129269 1038348664970462356 604430971757857481 1106581500345020431 788162934600883665 124672524392773463 534904853987097709 784497626701360420 402515001559379490 846591944896429860 761680713769800085 722846292535048189 621369111578909792 49581...
output:
677540798 680867675 52045645 749653697 117149309 98745394 144703758 451653184 32024693 46709896 369059733 553662418 458752268 960435128 532358935 539309779 75346669 836318204 802726648 805583841 638898297 909477278 272839963 91578899 339473301 354857597 203911979 419747649 790061684 294708791 920444...
result:
wrong answer 1st numbers differ - expected: '548320033', found: '677540798'