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 endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define ll long long
ll mod=998244353;
int inf=1000000007;
ll infl=1000000000000000007;
const int N=18;
unordered_map<int,int>DP[(1<<N)];
vector<int>inside[(1<<N)];
int G[N];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,m,a,b;
cin>>n>>m;
for(int i=0;i<m;i++)
{
cin>>a>>b;
a--,b--;
G[a]^=(1<<b);
G[b]^=(1<<a);
}
for(int i=0;i<(1<<n);i++)
{
for(int j=0;j<n;j++) if(i&(1<<j)) inside[i].pb(j);
}
DP[0][(1<<n)-1]=1;
for(int a=0;a<(1<<n);a++)
{
int d=(1<<n)-1-a;
for(int b=d;b>0;b=(b-1)&d)
{
int x=DP[a][b];
if(x==0) continue;
for(auto k:inside[b])
{
int A=a^(1<<k),B=(b&((1<<n)-(1<<(k+1))))|(G[k]&((1<<n)-1-a-(1<<k)));
int y=DP[A][B];
y+=x;
if(y>=mod) y-=mod;
DP[A][B]=y;
}
}
}
cout<<(ll)DP[(1<<n)-1][0]*(ll)m%mod*499122177%mod;
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... |