# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
666418 | 2022-11-28T15:12:27 Z | finn__ | Amusement Park (CEOI19_amusementpark) | C++17 | 0 ms | 212 KB |
#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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Incorrect | 0 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Incorrect | 0 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Incorrect | 0 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Incorrect | 0 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Incorrect | 0 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |