Submission #705607

#TimeUsernameProblemLanguageResultExecution timeMemory
705607finn__Amusement Park (CEOI19_amusementpark)C++17
42 / 100
36 ms564 KiB
#include <bits/stdc++.h> using namespace std; #define N 18 #define MOD 998244353 int64_t g[N], f[1 << N]; bitset<1 << N> is_independent; int main() { size_t n, m; cin >> n >> m; for (size_t i = 0; i < m; i++) { size_t u, v; cin >> u >> v; g[u - 1] ^= (1 << (v - 1)); g[v - 1] ^= (1 << (u - 1)); } for (size_t i = 0; i < 1U << n; i++) { is_independent[i] = 1; for (size_t j = 0; j < n; j++) if (i & (1 << j)) is_independent[i] = is_independent[i] && !(g[j] & i); } f[0] = 1; for (size_t i = 0; i < 1U << n; i++) { for (size_t j = i; j; j = (j - 1) & i) if (is_independent[j]) f[i] += f[i ^ j] * ((__builtin_popcount(j) & 1) ? 1 : -1); f[i] %= MOD; } cout << ((m * f[(1 << n) - 1] % MOD) * 499122177) % MOD << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...