This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// In the name of the God
#include <bits/stdc++.h>
#define ll long long
// #define int long long
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define pii pair <int, int>
#define smin(x, y) (x) = min((x), (y))
#define smax(x, y) (x) = max((x), (y))
#define all(x) (x).begin(), (x).end()
using namespace std;
const int inf = 1e9+7;
const int mod = 998244353;
const int maxn = 18;
int n, m, adj[1<<maxn], ind[1<<maxn], dp[1<<maxn];
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m;
for (int i = 0; i < m; i++) {
int v, u; cin >> v >> u;
adj[1<<(--v)] |= 1<<(--u);
adj[1<<u] |= 1<<v;
}
ind[0] = 1;
for (int mask = 1; mask < (1<<n); mask++) {
ind[mask] = ind[mask&(mask-1)]&!(adj[mask&(-mask)]&mask);
// cout << mask << ' ' << ind[mask] << '\n';
}
dp[0] = 1;
for (int mask = 1; mask < (1<<n); mask++) {
for (int smask = mask; smask; smask = (smask-1)&mask) {
if (ind[smask]) dp[mask] += (__builtin_parity(smask)*2-1)*dp[mask^smask];
}
}
cout << dp[(1<<n)-1]*m/2 << '\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... |