QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#917751 | #21608. 行列式 | segmentfault# | WA | 106ms | 4480kb | C++14 | 971b | 2025-02-27 14:49:37 | 2025-02-27 14:49:39 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 500 + 10,P=998244353;
int n,a[N][N];
inline int qpow(int a,int b){int res = 1;while(b){if(b&1)res=1ll*res*a%P;a=1ll*a*a%P,b>>=1;}return res;}
int calc(){
int res = 1;
for(int i = 1; i <= n ; ++ i){
int c = 0;
for(int j = i ; j <= n ; ++ j){
if(a[i][j]){c=j;break;}
}
if(!c){
return 0;
}
if(c!=i)swap(a[i],a[c]),res = P-res;
for(int j = i+1; j <= n ; ++ j){
int dif = a[j][i] * qpow(a[i][i],P-2);
for(int k = i ; k <= n ; ++ k)a[j][k] = (a[j][k] - (1ll*a[i][k]*dif)%P + P)%P;
}
}
for(int i = 1; i <= n ; ++ i)res = 1ll*res*a[i][i]%P;
return res;
}
int main(){
ios::sync_with_stdio(false),cin.tie(0);
cin >> n;
for(int i = 1; i <= n ; ++ i)
for(int j = 1; j <= n ; ++ j)cin >> a[i][j];
cout << calc() << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 106ms
memory: 4480kb
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:
928652176
result:
wrong answer 1st numbers differ - expected: '0', found: '928652176'