This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
long long dp[1<<18],g[18][18],u[1<<18],n,m;
int main(){
for(int i=0,x,y;(i||std::cin>>n>>m)&&i<m&&std::cin>>x>>y;++i)g[x-1][y-1]=true;
for(int m4sk=1;m4sk<1<<n;++m4sk)for(int i=0;i<n;++i)for(int j=0;j<n;++j)u[m4sk]|=g[i][j]&&(m4sk>>j&1)&&(m4sk>>i&1);
for(int m4sk=1;(dp[0]=1)&&m4sk<1<<n;++m4sk,(m4sk!=(1<<n)||(std::cout<<(dp[(1<<n)-1]*m%998244353*499122177%998244353+998244353)%998244353<<'\n')))for(int m3sk=m4sk;m3sk;m3sk=(m3sk-1)&m4sk)(dp[m4sk]+=dp[m4sk^m3sk]*(2*(__builtin_popcount(m3sk)&1)-1)*!u[m3sk])%=998244353;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |