# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
779320 | 2023-07-11T10:25:54 Z | nonono | Amusement Park (CEOI19_amusementpark) | C++14 | 1 ms | 340 KB |
#include <bits/stdc++.h> #define int long long using namespace std; const int mod = 998244353; const int N = 18; int n, m; int slide[N][N]; int Use[N][N]; long long dp1[1 << N], dp2[1 << N]; signed main(){ #define taskname "" if(fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } cin.tie(0)->sync_with_stdio(0); cin >> n >> m; for(int i = 1; i <= m; i ++){ int a, b; cin >> a >> b; a -- ; b -- ; slide[a][b] = 0; slide[b][a] = 1; Use[a][b] = 1; Use[b][a] = 1; } for(int i = 0; i < n; i ++) dp1[1 << i] = 1; for(int mask = 1; mask < (1 << n); mask ++){ for(int x = (1 << n) - 1 - mask; x > 0; x ^= x & (- x)){ int i = __builtin_ctz(x & (- x)); bool check = false; for(int y = mask; y > 0; y ^= y & (- y)){ int j = __builtin_ctz(y & (- y)); check = (check || Use[j][i]); } if(check){ for(int y = mask; y > 0; y ^= y & (- y)){ int j = __builtin_ctz(y & (- y)); (dp2[mask ^ (1 << i)] += dp1[mask] * slide[j][i]) %= mod; } (dp2[mask ^ (1 << i)] += dp2[mask]) %= mod; (dp1[mask ^ (1 << i)] += dp1[mask]) %= mod; } } } cout << dp2[(1 << n) - 1] << "\n"; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 328 KB | Output is correct |
3 | Incorrect | 1 ms | 340 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 328 KB | Output is correct |
3 | Incorrect | 1 ms | 340 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 328 KB | Output is correct |
3 | Incorrect | 1 ms | 340 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 328 KB | Output is correct |
3 | Incorrect | 1 ms | 340 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 328 KB | Output is correct |
3 | Incorrect | 1 ms | 340 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |