QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#343001 | #21608. 行列式 | Unreality# | WA | 258ms | 4900kb | C++14 | 1.4kb | 2024-03-01 20:55:26 | 2024-03-01 20:55:27 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define _rep(i_,a_,b_) for(int i_ = (a_); i_ <= (b_); ++i_)
#define mid ((L+R) >> 1)
#define multiCase() int testCnt = in(); _rep(curCase,1,testCnt)
#ifdef ONLINE_JUDGE
#define debug(...) 0
#else
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#endif
using ll = long long;
using pii = pair<int,int>;
int in(void) { int x; scanf("%d", &x); return x; } ll inl(void) { ll x; scanf("%lld", &x); return x; }
void out(int x) { printf("%d ", x); } void outln(int x) { printf("%d\n", x); }
void out(ll x) { printf("%lld ", x); } void outln(ll x) { printf("%lld\n", x); }
template<typename T> void chkmax(T &a, const T &b) { a = max(a, b); }
template<typename T> void chkmin(T &a, const T &b) { a = min(a, b); }
const int p = 998244353, kN = 505;
int n = in(), a[kN][kN];
int fpm(int a, int b) {
int r = 1;
for(;b;b >>= 1, a = 1ll * a * a % p) if(b & 1) r = 1ll * r * a % p;
return r;
}
int main() {
_rep(i,1,n) _rep(j,1,n) a[i][j] = in();
_rep(i,1,n) {
int b = i; while(b <= n && !a[b][i]) ++b;
if(b > n) { puts("0"); return 0; }
if(b != i) swap(i, b);
_rep(j,1,n) if(j != i) {
int scale = 1ll * a[j][i] * fpm(a[i][i], p - 2);
_rep(k,1,n) a[j][k] = (a[j][k] - 1ll * a[i][k] * scale % p + p) % p;
}
}
int det = 1;
_rep(i,1,n) det = 1ll * det * a[i][i] % p;
outln(det);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 258ms
memory: 4900kb
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:
249894136
result:
wrong answer 1st numbers differ - expected: '0', found: '249894136'