# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
486337 | 2021-11-11T10:17:18 Z | XII | Amusement Park (CEOI19_amusementpark) | C++17 | 0 ms | 204 KB |
#include <bits/stdc++.h> using namespace std; using ll = long long; #define fi first #define se second #define mp make_pair #define eb emplace_back #define ALL(x) (x).begin(), (x).end() #define FOR(i, a, b) for(int i = (a); i < (b); ++i) #define FORU(i, a, b) for(int i = (a); i <= (b); ++i) #define FORD(i, a, b) for(int i = (a); i >= (b); --i) #define IOS cin.tie(0)->sync_with_stdio(false); #define PROB "CEOI19_amusementpark" void Fi(){ if(fopen(PROB".inp", "r")){ freopen(PROB".inp", "r", stdin); freopen(PROB".out", "w", stdout); } } const int N = 18; int n, m; vector<int> adj[N], radj[N]; const int MOD = 998244353; int dp[1 << N]; /// number of reverse edge int f[1 << N]; /// number of state int main(){ IOS; Fi(); cin >> n >> m; FORU(i, 1, m){ int u, v; cin >> u >> v; --u, --v; adj[u].eb(v), radj[v].eb(u); } f[0] = 1; FOR(mask, 0, 1 << n){ FOR(u, 0, n) if(!(mask & (1 << u))){ int rev = 0; for(int v: adj[u]) if(mask & (1 << v)) ++rev; (dp[mask | (1 << u)] += f[mask] * rev + dp[mask]) %= MOD; (f[mask | (1 << u)] += f[mask]) %= MOD; } } // FOR(mask, 0, 1 << n){ // cout << bitset<10>(mask) << "\n"; // cout << f[mask] << " " << dp[mask] << "\n"; // } cout << dp[(1 << n) - 1]; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Incorrect | 0 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Incorrect | 0 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Incorrect | 0 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Incorrect | 0 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Incorrect | 0 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |