QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#479472#21608. 行列式grass8cow#RE 0ms0kbC++17851b2024-07-15 17:46:072024-07-15 17:46:08

Judging History

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

  • [2024-07-15 17:46:08]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-07-15 17:46:07]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int a[310][310],n;
const int mod=998244353;
int qpow(int a,int b){
    int c=1;
    for(;b;b>>=1){
        if(b&1)c=1ll*a*c%mod;
        a=1ll*a*a%mod;
    }
    return c;
}
void ad(int &x,int y){
    x+=y;if(x>=mod)x-=mod;
}
int det(){
    int an=1;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++)if(a[j][i])
            {swap(a[i],a[j]),an=mod-an;break;}
        an=1ll*an*a[i][i]%mod;
        int I=qpow(a[i][i],mod-2);
        for(int j=1;j<=n;j++)if(i!=j){
            int z=1ll*a[j][i]*I%mod;
            for(int k=i;k<=n;k++)
            ad(a[j][k],mod-1ll*a[i][k]*z%mod);
        }
    }
    return an;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)
    scanf("%d",&a[i][j]);
    printf("%d\n",det());
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

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:


result: