QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#918758#21608. 行列式RDFZchenyy#WA 99ms5760kbC++141.1kb2025-02-27 22:45:442025-02-27 22:45:54

Judging History

This is the latest submission verdict.

  • [2025-02-27 22:45:54]
  • Judged
  • Verdict: WA
  • Time: 99ms
  • Memory: 5760kb
  • [2025-02-27 22:45:44]
  • Submitted

answer

#include<bits/stdc++.h>

#define int long long

#define MAXN 505

int n;
int a[MAXN][MAXN];

const int mod=998244353;

int fpow(int a,int b,int p){
    int res=1;
    for(;b;b>>=1,a*=a,a%=p) if(b&1) res*=a,res%=p;
    return res;
}
int fpow(int a,int b){ return fpow(a,b,mod); }
int inv(int x){ return fpow(x,mod-2); }

signed main(){
    std::ios::sync_with_stdio(false);

    std::cin>>n; for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) std::cin>>a[i][j];
    int res=1;
    for(int i=1;i<=n;i++){
        int x=0; for(int j=i;j<=n;j++){
            if(a[j][i]){
                x=j; break;
            }
        }
        if(!x) return (std::cout<<0<<'\n'),0;
        for(int j=1;j<=n;j++) std::swap(a[x][j],a[i][j]);
        if(x!=i) res=(mod-res)%mod;
        res=res*a[i][i]; res%=mod; int t=inv(a[i][i]);
        for(int j=1;j<=n;j++) a[i][j]=(a[i][j]*t)%mod;
        for(int j=1;j<=n;j++){
            if(j==i) continue;
            int v=a[j][i];
            for(int p=1;p<=n;p++){
                a[j][p]+=(mod-v)*a[i][p];
            }
        }
    }
    std::cout<<res<<'\n';

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 99ms
memory: 5760kb

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:

-645467659

result:

wrong answer 1st numbers differ - expected: '0', found: '-645467659'