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"
using namespace std;
#define ll long long
#define pb push_back
#define _ << " " <<
typedef pair<int, int> pii;
typedef array<int, 3> tii;
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 998244353;
int main(){
int n, m; cin >> n >> m;
const int N = (1 << n);
vector<vector<bool> > adj(n, vector<bool> (n, 0));
vector<ll> cnt(N, 0), res(N, 0);
for(int i = 0; i<m; ++i){
int a, b; cin >> a >> b; a--; b--;
adj[a][b] = adj[b][a] = 1;
}
vector<bool> indset(N, 1);
for(int i=0; i<N; ++i)
for(int j=0; j<n; ++j)
cnt[i] += (!!((1<<j)&i));
for(int i=0; i<N; ++i)
for(int j=0; j<min(n, i); ++j)
for(int k=0; k<j; ++k)
if(adj[j][k] & !!(1&(i>>j)) & !!(1&(i>>k)))
indset[i] = 0;
res[0] = 1;
for(int i=1; i<N; ++i){
for(int j = i; j; j = (i&(j-1))){
if(cnt[j]%2) res[i] = (res[i] + indset[j]*res[i^j])%mod;
else res[i] = (res[i] + mod - indset[j]*res[i^j])%mod;
}
}
ll ans = ((res[N-1] + mod)*m)%mod;
ans = (ans*(mod+1)/2)%mod;
cout << ans << endl;
}
# | 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... |