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 int long long
#define MOD 998244353
int adj[20];
map<int, int> dp[1<<18];
int32_t main(){
int n, m;
cin>>n>>m;
for(int i=1;i<=m;++i){
int a, b;
cin>>a>>b;
a--, b--;
adj[a]|=(1<<b);
adj[b]|=(1<<a);
}
dp[0][(1<<n)-1]=1;
for(int mask=0;mask<(1<<n);++mask){
for(auto it:dp[mask]){
int mask2=it.first;
int nr=it.second;
for(int x=0;x<n;++x){
if(mask2&(1<<x)){
mask2=mask2&(((1<<n)-1)-((1<<(x+1))-1));
mask2=mask2|((adj[x]|mask)^mask);
dp[mask|(1<<x)][mask2]+=nr;
dp[mask|(1<<x)][mask2]%=MOD;
}
}
}
}
int sol=dp[(1<<n)-1][0];
sol=(sol*m)%MOD;
sol=(sol*(MOD+1)/2)%MOD;
cout<<sol<<"\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... |