Submission #705608

#TimeUsernameProblemLanguageResultExecution timeMemory
705608finn__Amusement Park (CEOI19_amusementpark)C++17
42 / 100
34 ms548 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() { int64_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'; }

Compilation message (stderr)

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:15:26: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int64_t' {aka 'long int'} [-Wsign-compare]
   15 |     for (size_t i = 0; i < m; i++)
      |                        ~~^~~
amusementpark.cpp:26:30: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int64_t' {aka 'long int'} [-Wsign-compare]
   26 |         for (size_t j = 0; j < n; j++)
      |                            ~~^~~
#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...