#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define pi pair<int,int>
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define compact(v) (v).erase(unique(all(v)), (v).end())
template<class T> using upq = priority_queue<T, vector<T>, greater<T>>;
template<class T> int lwrbound(const vector<T>& a, const T& b, const int s = 0){return int(lower_bound(s + all(a), b) - a.begin());}
template<class T> int uprbound(const vector<T>& a, const T& b, const int s = 0){return int(upper_bound(s + all(a), b) - a.begin());}
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define ROF(i, a, b) for(int i = (a); i >= (b); i--)
#define sumof(x) accumulate(all(x), 0ll)
#define dbg(x) "[" << #x " = " << (x) << "]"
#define el "\n"
using ll = long long;
using ld = long double;
template<class T> bool ckmx(T& a, const T b){return (a < b ? a = b, true : false);}
template<class T> bool ckmn(T& a, const T b){return (a > b ? a = b, true : false);}
const int MOD = 998244353;
void add(int& x, int y){
x += y;
if(x >= MOD) x -= MOD;
}
int mul(int x, int y){
return 1ll * x * y % MOD;
}
int bpow(int a, int b){
int ans = 1;
for(; b; b >>= 1, a = mul(a, a))
if(b & 1) ans = mul(ans, a);
return ans;
}
void Main()
{
int N, M; cin >> N >> M;
vi E(N);
FOR(i, 1, M){
int u, v; cin >> u >> v;
--u, --v;
E[u] |= (1 << v), E[v] |= (1 << u);
}
vector<vector<pi>> dp((1 << N));
dp[0].eb((1 << N) - 1, 1);
FOR(mask, 0, (1 << N) - 1) if(sz(dp[mask])){
sort(all(dp[mask]));
{
vector<pi> cdp;
int sum = dp[mask][0].se;
FOR(i, 1, sz(dp[mask]) - 1){
if(dp[mask][i].fi == dp[mask][i - 1].fi){
add(sum, dp[mask][i].se);
}
else cdp.eb(dp[mask][i - 1].fi, sum), sum = dp[mask][i].se;
}
cdp.eb(dp[mask].back().fi, sum);
swap(cdp, dp[mask]);
}
int full = (1 << N) - 1;
for(pi e : dp[mask]){
int B = e.fi, vdp = e.se;
for(int tm = B; tm; tm -= (tm & -tm)){
int i = 31 - __builtin_clz((tm & -tm));
int nB = (B & (full ^ ((1 << (i + 1)) - 1)));
nB = nB | (E[i] ^ (E[i] & mask));
dp[mask | (1 << i)].eb(nB, vdp);
//cout << mask <<" " << (mask | (1 << i)) <<" " << bitset<3>(B) <<" " << bitset<3>(nB) <<" " << vdp << el;
}
}
}
int ans = 0;
for(pi e : dp[(1 << N) - 1]){
add(ans, e.se);
}
cout << mul(ans, mul(M, bpow(2, MOD - 2))) << el;
}
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#define name "InvMOD"
if(fopen(name".INP", "r")){
freopen(name".INP", "r", stdin);
freopen(name".OUT", "w", stdout);
}
int t = 1; while(t--) Main();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
amusementpark.cpp: In function 'int32_t main()':
amusementpark.cpp:107:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
107 | freopen(name".INP", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
amusementpark.cpp:108:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
108 | freopen(name".OUT", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~| # | 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... |