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;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
const int M = 998244353;
auto add = [&](int &x, int y) {
if ((x += y) >= M) {
x -= M;
}
if (x < 0) {
x += M;
}
};
auto pw = [&](int a, int b) {
int res = 1;
for (; b; a = (long long) a * a % M, b /= 2) {
if (b & 1) {
res = (long long) res * a % M;
}
}
return res;
};
int n, m; cin >> n >> m;
vector a(n, vector<bool>(n));
for (int i = 0; i < m; ++i) {
int u, v; cin >> u >> v; --u, --v;
a[u][v] = a[v][u] = 1;
}
vector<int> ind(1 << n, 1);
for (int i = 0; i < 1 << n; ++i) {
for (int j = 0; j < n; ++j) {
if (i >> j & 1) {
for (int k = j + 1; k < n; ++k) {
if (i >> k & 1) {
ind[i] &= !a[j][k];
}
}
}
}
}
vector<int> cnt(1 << n);
cnt[0] = 1;
for (int i = 1; i < 1 << n; ++i) {
for (int j = i; j; j = (j - 1) & i) {
if (ind[j]) {
if (__builtin_popcount(j) & 1) {
add(cnt[i], cnt[i ^ j]);
} else {
add(cnt[i], -cnt[i ^ j]);
}
}
}
}
cout << (long long) cnt.back() * m % M * pw(2, M - 2) % M;
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... |