QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#93394 | #21608. 行列式 | myee# | WA | 112ms | 3592kb | C++11 | 2.5kb | 2023-03-31 19:30:09 | 2023-03-31 19:30:11 |
Judging History
answer
// 那就是希望。
// 即便需要取模,也是光明。
#include <algorithm>
#include <stdio.h>
#include <vector>
typedef long long llt;
typedef unsigned uint;typedef unsigned long long ullt;
typedef bool bol;typedef char chr;typedef void voi;
typedef double dbl;
template<typename T>bol _max(T&a,T b){return(a<b)?a=b,true:false;}
template<typename T>bol _min(T&a,T b){return(b<a)?a=b,true:false;}
template<typename T>T lowbit(T n){return n&-n;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T lcm(T a,T b){return(a!=0||b!=0)?a/gcd(a,b)*b:(T)0;}
template<typename T>T exgcd(T a,T b,T&x,T&y){if(b!=0){T ans=exgcd(b,a%b,y,x);y-=a/b*x;return ans;}else return y=0,x=1,a;}
template<typename T>T power(T base,T index,T mod)
{
T ans=1%mod;
while(index)
{
if(index&1)ans=ans*base%mod;
base=base*base%mod,index>>=1;
}
return ans;
}
const ullt Mod=998244353;
struct modint
{
ullt v;
modint():v(0){}
modint(ullt v):v(v%Mod){}
voi read(){scanf("%llu",&v);}
voi print(){printf("%llu",v);}
voi println(){print(),putchar('\n');}
ullt&operator()(){return v;}
friend modint operator+(modint a,modint b){return a()+b();}
friend modint operator-(modint a,modint b){return a()+Mod-b();}
friend modint operator*(modint a,modint b){return a()*b();}
friend modint operator/(modint a,modint b){return a*b.inv();}
friend modint operator^(modint a,ullt b){
modint ans(1);
while(b){
if(b&1)ans*=a;
a*=a,b>>=1;
}
return ans;
}
modint inv(){return(*this)^(Mod-2);}
modint&operator+=(modint b){return*this=*this+b;}
modint&operator-=(modint b){return*this=*this-b;}
modint&operator*=(modint b){return*this=*this*b;}
modint&operator/=(modint b){return*this=*this/b;}
modint&operator^=(ullt b){return*this=(*this)^b;}
};
modint A[505][505];
uint n;
modint det(){
modint ans(1);
for(uint i=0;i<n;i++)
{
for(uint j=i;j<n;j++)if(A[j][i]()){std::swap(A[i],A[j]);break;}
if(!A[i][i]())return 0;
ans*=A[i][i],A[i][i]=A[i][i].inv();
for(uint j=i;j<n;j++)A[i][j]*=A[i][i];
for(uint j=i+1;j<n;j++)
for(uint k=i+1;k<n;k++)
A[j][k]-=A[j][i]*A[i][k];
}
return ans;
}
int main()
{
#ifdef MYEE
freopen("QAQ.in","r",stdin);
freopen("QAQ.out","w",stdout);
#endif
scanf("%u",&n);
for(uint i=0;i<n;i++)for(uint j=0;j<n;j++)A[i][j].read();
det().println();
return 0;
}
// 那就是希望。
// 即便需要取模,也是光明。
/*
g++ code.cpp -o code -std=c++14 -Wall -fsanitize=undefined,address -DMYEE
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 112ms
memory: 3592kb
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:
921871398
result:
wrong answer 1st numbers differ - expected: '0', found: '921871398'