QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#130702 | #21608. 行列式 | youngsystem# | WA | 80ms | 4576kb | C++20 | 1.1kb | 2023-07-24 20:11:34 | 2023-07-24 20:11:36 |
Judging History
answer
#include<bits/stdc++.h>
#define mod 998244353
using namespace std;
inline int read()
{
int n=0,f=1,ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-')f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9')
{
n=n*10+ch-'0';
ch=getchar();
}
return n*f;
}
int a[505][505];
int ksm(int n,int k)
{
int ans=1;
while(k>=1)
{
if(k&1)ans=1LL*ans*n%mod;
k>>=1;
n=1LL*n*n%mod;
}
return ans;
}
int main()
{
int n;
n=read();
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
a[i][j]=read();
}
}
int ans=1;
for(int i=1;i<=n;i++)
{
int sth=0;
for(int j=i;j<=n;j++)
{
if(a[j][i]!=0)
{
sth=j;
break;
}
}
if(sth==0)
{
printf("0\n");
break;
}
if(sth!=i)
{
for(int j=i;j<=n;j++)swap(a[i][j],a[sth][j]);
ans=mod-ans;
}
ans=1LL*ans*a[i][i]%mod;
sth=ksm(a[i][i],mod-2);
for(int j=i;j<=n;j++)a[i][j]=1LL*a[i][j]*sth%mod;
for(int j=i+1;j<=n;j++)
{
sth=a[j][i];
for(int k=i;k<=n;k++)a[j][k]=(a[j][k]+mod-1LL*sth*a[i][k]%mod)%mod;
}
}
printf("%d\n",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 80ms
memory: 4576kb
input:
494 507979999 844753235 308697058 577366689 725069158 935333779 504374900 25818576 590205152 640101368 622693010 938297920 872742027 301114974 734834637 556531110 842083217 975440662 921805913 100862321 393656903 213191224 795146059 30475198 812681603 711143306 28681751 642978178 605226383 94538558 ...
output:
0 784961113
result:
wrong answer Output contains longer sequence [length = 2], but answer contains 1 elements