QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#481188 | #21608. 行列式 | lmeowdn# | TL | 0ms | 0kb | C++14 | 1.6kb | 2024-07-16 21:15:36 | 2024-07-16 21:15:36 |
answer
//Shirasu Azusa 2024.7
#include <bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x) {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x) {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x) {return (x==0?-1:__builtin_ctzll(x));}
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef tuple<int,int,int> tiii;
int read() {
int x=0,w=1; char c=getchar();
while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();}
return x*w;
}
const int N=505,mod=998244353;
int n,a[N][N];
signed main() {
n=read(); int ans=1;
rep(i,1,n) rep(j,1,n) a[i][j]=read();
rep(i,1,n) {
int r=i; while(r<=n&&!a[r][i]) r++;
if(r==n+1) return puts("0"), 0; else swap(a[i],a[r]);
rep(j,i+1,n) {
while(a[j][i]) {
int pp=a[j][i]/a[i][i];
rep(k,1,n) a[j][k]=(a[j][k]-pp*a[i][k])%mod;
}
}
ans=ans*a[i][i]%mod;
}
ans=(ans+mod)%mod;
printf("%lld\n",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
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 ...