QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#548216#6347. XOR DeterminantBFSDFS123#WA 85ms4300kbC++141.4kb2024-09-05 16:26:372024-09-05 16:26:37

Judging History

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

  • [2024-09-05 16:26:37]
  • 评测
  • 测评结果:WA
  • 用时:85ms
  • 内存:4300kb
  • [2024-09-05 16:26:37]
  • 提交

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)
{
	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 j,k,r=1,fh=0,l;
	for(int i=1;i<=n;i++)
	{
		k=i;
		for(j=i;j<=n;j++)
		{
			if(C[j][i])
			{
				k=j;
				break;
			}
		}
		if(C[k][i]==0)
		{
			return 0;
		}
		for(++j;j<=n;j++)
		{
			if(C[j][i] && C[j][i]<C[k][i])
			{
				k=j;
			}
		}
		if(i!=k)
		{
			swap(C[k],C[i]);
			fh^=1;
		}
		for(j=i+1;j<=n;j++)
		{
			if(C[j][i]>C[i][i])
			{
				swap(C[i],C[j]);
				fh^=1;
			}
			while(C[j][i])
			{
				l=C[i][i]/C[j][i];
				for(k=i;k<=n;k++)
				{
					C[i][k]=(C[i][k]+(ll)(Mod-l)*C[j][k])%Mod;
				}
				swap(C[j],C[i]);
				fh^=1;
			}
		}
		r=(ll)r*C[i][i]%Mod;
	}
	if(fh) return (Mod-r+Mod)%Mod;
	else return (r+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: 4088kb

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: 1ms
memory: 4064kb

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: 85ms
memory: 4300kb

input:

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

output:

762912265
327289441
978369509
170999703
928634264
944035684
960619762
260580571
62808108
184362405
80617899
184598214
359242999
389403902
28116033
625472793
458635452
431284858
857655962
284436415
349121152
717689368
860729990
807929783
462315052
773820749
835872419
382670480
732018924
887144888
541...

result:

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