QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#548244#6347. XOR DeterminantBFSDFS123#WA 4ms4284kbC++141.1kb2024-09-05 16:34:302024-09-05 16:34:33

Judging History

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

  • [2024-09-05 16:34:33]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:4284kb
  • [2024-09-05 16:34:30]
  • 提交

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)
{
	a=(a%Mod+Mod)%Mod;
	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: 3996kb

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: 4ms
memory: 4284kb

input:

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

output:

242077549
728089129
690253727
570384536
322564901
85026398
993085497
813808933
821806477
608084343
447622829
730198961
615631811
698956924
724290619
80475883
390805230
105240274
214061272
186065349
533622912
178958251
192901718
507398805
441927666
888009689
694437910
118667297
657679851
493065551
44...

result:

wrong answer 1st numbers differ - expected: '548320033', found: '242077549'