Submission #674819

#TimeUsernameProblemLanguageResultExecution timeMemory
674819vovikAmusement Park (CEOI19_amusementpark)C++17
100 / 100
2545 ms4692 KiB
#include <bits/stdc++.h> long long dp[1 << 18], g[18][18], babyTron[1 << 18], n, m; int main() { for (int i = 0, x, y; (i || std::cin >> n >> m) && i < m && std::cin >> x >> y; ++i) g[x - 1][y - 1] = true; for (int m4sk = 1; m4sk < 1 << n; ++m4sk) for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) babyTron[m4sk] |= g[i][j] && (m4sk >> j & 1) && (m4sk >> i & 1); for (int m4sk = 1; (dp[0] = 1) && m4sk < 1 << n; ++m4sk) for (int m3sk = m4sk; m3sk; m3sk = (m3sk - 1) & m4sk) (dp[m4sk] += dp[m4sk ^ m3sk] * (2 * (__builtin_popcount(m3sk) & 1) - 1) * !babyTron[m3sk]) %= 998244353; std::cout << (dp[(1 << n) - 1] * m % 998244353 * ((998244354) / 2) % 998244353 + 998244353) % 998244353 << '\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...