#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define fi first
#define se second
const int mod = 998244353;
const int maxn = 18;
int n, m;
int dp[1 << maxn];
bool edge[maxn][maxn];
vector<pii > edges;
void solve() {
cin >> n >> m;
if(n == 1) {
cout << "0\n";
return;
}
for(int i = 0; i < m; i++) {
int a, b;
cin >> a >> b;
a--;
b--;
edge[a][b] = edge[b][a] = true;
edges.pb(mp(a, b));
}
for(int mask = 1; mask < (1 << n); mask++) {
if(__builtin_popcount(mask) == 1) {
dp[mask] = 1;
continue;
}
int a = -1;
for(int i = 0; i < n; i++) {
if(mask & (1 << i)) {
a = i;
break;
}
}
int cnt = 0;
for(int i = 0; i < n; i++) {
if(edge[i][a] && (mask & (1 << i))) {
cnt++;
}
}
dp[mask] = ((cnt + 1) * dp[mask ^ (1 << a)]) % mod;
}
int ans = (m * dp[(1 << n) - 1]) % mod;
if(ans % 2 == 1) {
ans = (ans + mod) / 2;
} else {
ans = ans / 2;
}
cout << ans << "\n";
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |