Submission #666418

#TimeUsernameProblemLanguageResultExecution timeMemory
666418finn__Amusement Park (CEOI19_amusementpark)C++17
0 / 100
0 ms212 KiB
#include <bits/stdc++.h> using namespace std; #define MOD 998244353 int main() { size_t n, m; cin >> n >> m; vector<vector<bool>> g(n, vector<bool>(n, 0)); for (size_t i = 0; i < m; i++) { unsigned u, v; cin >> u >> v; g[u - 1][v - 1] = 1; } vector<uint64_t> dp(1 << n, 0), nways(1 << n, 0); nways[0] = 1; for (unsigned i = 0; i < 1 << n; i++) { for (unsigned j = 0; j < n; j++) { if (!(i & (1 << j))) { uint64_t c = 0; for (unsigned k = 0; k < n; k++) c += (i & (1 << k)) && g[k][j]; dp[i ^ (1 << j)] = (dp[i ^ (1 << j)] + dp[i] + c * nways[i]) % MOD; nways[i ^ (1 << j)] = (nways[i ^ (1 << j)] + nways[i]) % MOD; } } } cout << dp[(1 << n) - 1] << '\n'; }

Compilation message (stderr)

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:22:28: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   22 |     for (unsigned i = 0; i < 1 << n; i++)
      |                          ~~^~~~~~~~
#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...