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
// const ll MOD = 1e9+7;
const ll MOD = 998244353;
const ll N=18;
const ll inv=499122177;
int edges[N+1];
ll ans[N+1];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
for(int i=0;i<=N;i++)edges[i]=0;
for(int i=0;i<=N;i++)ans[i]=0;
int n,m,a,b;
cin>>n>>m;
for (int i = 0; i < m; i++)
{
cin>>a>>b;
a--;
b--;
edges[a]+=(1<<b);
edges[b]+=(1<<a);
}
ans[0]=1;
for (int i = 1; i < (1<<n); i++)
{
for (int j = i; j > 0; j=((j-1)&i))
{
int check=1,cnt=0;
for (int k = 0; k < n; k++)
{
if((j^(1<<k))<j){
if((edges[k]&j))check=0;
}
if(!check)break;
}
if(!check)continue;
for (int k = 0; k < n; k++)if((j^(1<<k))<j)cnt++;
cnt%=2;
// cout<<i<<" "<<j<<" "<<cnt<<"\n";
if(cnt){
ans[i]+=ans[i^j];
}else{
ans[i]-=ans[i^j];
ans[i]+=MOD;
}
ans[i]%=MOD;
}
}
cout<<(((ans[(1<<n)-1]*m)%MOD)*inv)%MOD<<"\n";
return 0;
}
# | 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... |