# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
208157 | 2020-03-10T06:33:53 Z | E869120 | Amusement Park (CEOI19_amusementpark) | C++14 | 196 ms | 14584 KB |
#include <iostream> #include <algorithm> #include <vector> using namespace std; #pragma warning (disable: 4996) int mod = 998244353; int N, M, A[1009], B[1009]; int dp[15000000], power3[19]; vector<int> X[1009]; int main() { cin >> N >> M; for (int i = 1; i <= M; i++) { cin >> A[i] >> B[i]; A[i]--; B[i]--; } for (int i = 1; i <= M; i++) { X[A[i]].push_back(B[i]); X[B[i]].push_back(A[i]); } power3[0] = 1; for (int i = 1; i <= N; i++) power3[i] = 3LL * power3[i - 1]; for (int i = 0; i < N; i++) { int ret = 2 * power3[i]; for (int j = i + 1; j < N; j++) ret += power3[j]; for (int j : X[i]) { if (j < i) ret += power3[j]; } dp[ret] = 1; } for (int i = 0; i < power3[N]; i++) { if (dp[i] == 0) continue; int col[15]; for (int j = 0; j < N; j++) col[j] = (i / power3[j]) % 3; for (int j = 0; j < N; j++) { if (col[j] != 1) continue; int ret = i + power3[j]; for (int k = 0; k < j; k++) { if (col[k] == 1) ret -= power3[k]; } for (int k : X[j]) { if ((col[k] == 1 && k < j) || col[k] == 0) ret += power3[k]; } dp[ret] += dp[i]; if (dp[ret] >= mod) dp[ret] -= mod; } } long long val = dp[power3[N] - 1]; val *= M; val %= mod; if (val % 2 == 1) val += mod; val /= 2LL; cout << val << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 4 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Correct | 5 ms | 376 KB | Output is correct |
6 | Correct | 5 ms | 376 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 7 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 4 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Correct | 5 ms | 376 KB | Output is correct |
6 | Correct | 5 ms | 376 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 7 ms | 376 KB | Output is correct |
9 | Correct | 4 ms | 376 KB | Output is correct |
10 | Correct | 5 ms | 376 KB | Output is correct |
11 | Correct | 5 ms | 376 KB | Output is correct |
12 | Correct | 6 ms | 376 KB | Output is correct |
13 | Correct | 4 ms | 376 KB | Output is correct |
14 | Correct | 5 ms | 380 KB | Output is correct |
15 | Correct | 5 ms | 376 KB | Output is correct |
16 | Correct | 4 ms | 376 KB | Output is correct |
17 | Correct | 5 ms | 376 KB | Output is correct |
18 | Correct | 5 ms | 376 KB | Output is correct |
19 | Correct | 5 ms | 380 KB | Output is correct |
20 | Correct | 5 ms | 376 KB | Output is correct |
21 | Correct | 4 ms | 376 KB | Output is correct |
22 | Correct | 5 ms | 376 KB | Output is correct |
23 | Correct | 5 ms | 376 KB | Output is correct |
24 | Correct | 5 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 4 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Correct | 5 ms | 376 KB | Output is correct |
6 | Correct | 5 ms | 376 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 7 ms | 376 KB | Output is correct |
9 | Correct | 4 ms | 376 KB | Output is correct |
10 | Correct | 5 ms | 376 KB | Output is correct |
11 | Correct | 5 ms | 376 KB | Output is correct |
12 | Correct | 6 ms | 376 KB | Output is correct |
13 | Correct | 4 ms | 376 KB | Output is correct |
14 | Correct | 5 ms | 380 KB | Output is correct |
15 | Correct | 5 ms | 376 KB | Output is correct |
16 | Correct | 4 ms | 376 KB | Output is correct |
17 | Correct | 5 ms | 376 KB | Output is correct |
18 | Correct | 5 ms | 376 KB | Output is correct |
19 | Correct | 5 ms | 380 KB | Output is correct |
20 | Correct | 5 ms | 376 KB | Output is correct |
21 | Correct | 4 ms | 376 KB | Output is correct |
22 | Correct | 5 ms | 376 KB | Output is correct |
23 | Correct | 5 ms | 376 KB | Output is correct |
24 | Correct | 5 ms | 376 KB | Output is correct |
25 | Correct | 5 ms | 376 KB | Output is correct |
26 | Correct | 5 ms | 376 KB | Output is correct |
27 | Correct | 5 ms | 376 KB | Output is correct |
28 | Correct | 5 ms | 376 KB | Output is correct |
29 | Correct | 5 ms | 376 KB | Output is correct |
30 | Correct | 5 ms | 376 KB | Output is correct |
31 | Correct | 5 ms | 376 KB | Output is correct |
32 | Correct | 5 ms | 376 KB | Output is correct |
33 | Correct | 5 ms | 376 KB | Output is correct |
34 | Correct | 5 ms | 376 KB | Output is correct |
35 | Correct | 5 ms | 376 KB | Output is correct |
36 | Correct | 5 ms | 376 KB | Output is correct |
37 | Correct | 5 ms | 376 KB | Output is correct |
38 | Correct | 5 ms | 376 KB | Output is correct |
39 | Correct | 5 ms | 376 KB | Output is correct |
40 | Correct | 5 ms | 376 KB | Output is correct |
41 | Correct | 5 ms | 376 KB | Output is correct |
42 | Correct | 5 ms | 376 KB | Output is correct |
43 | Correct | 5 ms | 376 KB | Output is correct |
44 | Correct | 5 ms | 380 KB | Output is correct |
45 | Correct | 5 ms | 376 KB | Output is correct |
46 | Correct | 5 ms | 376 KB | Output is correct |
47 | Correct | 5 ms | 376 KB | Output is correct |
48 | Correct | 5 ms | 376 KB | Output is correct |
49 | Correct | 5 ms | 376 KB | Output is correct |
50 | Correct | 5 ms | 376 KB | Output is correct |
51 | Correct | 5 ms | 376 KB | Output is correct |
52 | Correct | 5 ms | 376 KB | Output is correct |
53 | Correct | 5 ms | 508 KB | Output is correct |
54 | Correct | 5 ms | 504 KB | Output is correct |
55 | Correct | 5 ms | 376 KB | Output is correct |
56 | Correct | 6 ms | 376 KB | Output is correct |
57 | Correct | 6 ms | 504 KB | Output is correct |
58 | Correct | 6 ms | 508 KB | Output is correct |
59 | Correct | 6 ms | 380 KB | Output is correct |
60 | Correct | 6 ms | 376 KB | Output is correct |
61 | Correct | 5 ms | 504 KB | Output is correct |
62 | Correct | 6 ms | 504 KB | Output is correct |
63 | Correct | 5 ms | 376 KB | Output is correct |
64 | Correct | 6 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 4 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Correct | 5 ms | 376 KB | Output is correct |
6 | Correct | 5 ms | 376 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 7 ms | 376 KB | Output is correct |
9 | Correct | 4 ms | 376 KB | Output is correct |
10 | Correct | 5 ms | 376 KB | Output is correct |
11 | Correct | 5 ms | 376 KB | Output is correct |
12 | Correct | 6 ms | 376 KB | Output is correct |
13 | Correct | 4 ms | 376 KB | Output is correct |
14 | Correct | 5 ms | 380 KB | Output is correct |
15 | Correct | 5 ms | 376 KB | Output is correct |
16 | Correct | 4 ms | 376 KB | Output is correct |
17 | Correct | 5 ms | 376 KB | Output is correct |
18 | Correct | 5 ms | 376 KB | Output is correct |
19 | Correct | 5 ms | 380 KB | Output is correct |
20 | Correct | 5 ms | 376 KB | Output is correct |
21 | Correct | 4 ms | 376 KB | Output is correct |
22 | Correct | 5 ms | 376 KB | Output is correct |
23 | Correct | 5 ms | 376 KB | Output is correct |
24 | Correct | 5 ms | 376 KB | Output is correct |
25 | Correct | 5 ms | 376 KB | Output is correct |
26 | Correct | 5 ms | 376 KB | Output is correct |
27 | Correct | 5 ms | 376 KB | Output is correct |
28 | Correct | 5 ms | 376 KB | Output is correct |
29 | Correct | 5 ms | 376 KB | Output is correct |
30 | Correct | 5 ms | 376 KB | Output is correct |
31 | Correct | 5 ms | 376 KB | Output is correct |
32 | Correct | 5 ms | 376 KB | Output is correct |
33 | Correct | 5 ms | 376 KB | Output is correct |
34 | Correct | 5 ms | 376 KB | Output is correct |
35 | Correct | 5 ms | 376 KB | Output is correct |
36 | Correct | 5 ms | 376 KB | Output is correct |
37 | Correct | 5 ms | 376 KB | Output is correct |
38 | Correct | 5 ms | 376 KB | Output is correct |
39 | Correct | 5 ms | 376 KB | Output is correct |
40 | Correct | 5 ms | 376 KB | Output is correct |
41 | Correct | 5 ms | 376 KB | Output is correct |
42 | Correct | 5 ms | 376 KB | Output is correct |
43 | Correct | 5 ms | 376 KB | Output is correct |
44 | Correct | 5 ms | 380 KB | Output is correct |
45 | Correct | 5 ms | 376 KB | Output is correct |
46 | Correct | 5 ms | 376 KB | Output is correct |
47 | Correct | 5 ms | 376 KB | Output is correct |
48 | Correct | 5 ms | 376 KB | Output is correct |
49 | Correct | 5 ms | 376 KB | Output is correct |
50 | Correct | 5 ms | 376 KB | Output is correct |
51 | Correct | 5 ms | 376 KB | Output is correct |
52 | Correct | 5 ms | 376 KB | Output is correct |
53 | Correct | 5 ms | 508 KB | Output is correct |
54 | Correct | 5 ms | 504 KB | Output is correct |
55 | Correct | 5 ms | 376 KB | Output is correct |
56 | Correct | 6 ms | 376 KB | Output is correct |
57 | Correct | 6 ms | 504 KB | Output is correct |
58 | Correct | 6 ms | 508 KB | Output is correct |
59 | Correct | 6 ms | 380 KB | Output is correct |
60 | Correct | 6 ms | 376 KB | Output is correct |
61 | Correct | 5 ms | 504 KB | Output is correct |
62 | Correct | 6 ms | 504 KB | Output is correct |
63 | Correct | 5 ms | 376 KB | Output is correct |
64 | Correct | 6 ms | 376 KB | Output is correct |
65 | Correct | 44 ms | 4344 KB | Output is correct |
66 | Correct | 65 ms | 4984 KB | Output is correct |
67 | Correct | 65 ms | 4216 KB | Output is correct |
68 | Correct | 75 ms | 4088 KB | Output is correct |
69 | Correct | 24 ms | 3576 KB | Output is correct |
70 | Correct | 28 ms | 3580 KB | Output is correct |
71 | Correct | 28 ms | 3192 KB | Output is correct |
72 | Correct | 28 ms | 2552 KB | Output is correct |
73 | Correct | 32 ms | 3576 KB | Output is correct |
74 | Correct | 32 ms | 3192 KB | Output is correct |
75 | Correct | 32 ms | 2808 KB | Output is correct |
76 | Correct | 32 ms | 2296 KB | Output is correct |
77 | Correct | 98 ms | 14584 KB | Output is correct |
78 | Correct | 109 ms | 13180 KB | Output is correct |
79 | Correct | 157 ms | 13176 KB | Output is correct |
80 | Correct | 156 ms | 10104 KB | Output is correct |
81 | Correct | 180 ms | 10488 KB | Output is correct |
82 | Correct | 192 ms | 10104 KB | Output is correct |
83 | Correct | 196 ms | 7544 KB | Output is correct |
84 | Correct | 165 ms | 6520 KB | Output is correct |
85 | Correct | 54 ms | 7800 KB | Output is correct |
86 | Correct | 64 ms | 7800 KB | Output is correct |
87 | Correct | 64 ms | 7032 KB | Output is correct |
88 | Correct | 65 ms | 5496 KB | Output is correct |
89 | Correct | 81 ms | 7892 KB | Output is correct |
90 | Correct | 73 ms | 7032 KB | Output is correct |
91 | Correct | 71 ms | 6136 KB | Output is correct |
92 | Correct | 73 ms | 5112 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 4 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Correct | 5 ms | 376 KB | Output is correct |
6 | Correct | 5 ms | 376 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 7 ms | 376 KB | Output is correct |
9 | Correct | 4 ms | 376 KB | Output is correct |
10 | Correct | 5 ms | 376 KB | Output is correct |
11 | Correct | 5 ms | 376 KB | Output is correct |
12 | Correct | 6 ms | 376 KB | Output is correct |
13 | Correct | 4 ms | 376 KB | Output is correct |
14 | Correct | 5 ms | 380 KB | Output is correct |
15 | Correct | 5 ms | 376 KB | Output is correct |
16 | Correct | 4 ms | 376 KB | Output is correct |
17 | Correct | 5 ms | 376 KB | Output is correct |
18 | Correct | 5 ms | 376 KB | Output is correct |
19 | Correct | 5 ms | 380 KB | Output is correct |
20 | Correct | 5 ms | 376 KB | Output is correct |
21 | Correct | 4 ms | 376 KB | Output is correct |
22 | Correct | 5 ms | 376 KB | Output is correct |
23 | Correct | 5 ms | 376 KB | Output is correct |
24 | Correct | 5 ms | 376 KB | Output is correct |
25 | Correct | 5 ms | 376 KB | Output is correct |
26 | Correct | 5 ms | 376 KB | Output is correct |
27 | Correct | 5 ms | 376 KB | Output is correct |
28 | Correct | 5 ms | 376 KB | Output is correct |
29 | Correct | 5 ms | 376 KB | Output is correct |
30 | Correct | 5 ms | 376 KB | Output is correct |
31 | Correct | 5 ms | 376 KB | Output is correct |
32 | Correct | 5 ms | 376 KB | Output is correct |
33 | Correct | 5 ms | 376 KB | Output is correct |
34 | Correct | 5 ms | 376 KB | Output is correct |
35 | Correct | 5 ms | 376 KB | Output is correct |
36 | Correct | 5 ms | 376 KB | Output is correct |
37 | Correct | 5 ms | 376 KB | Output is correct |
38 | Correct | 5 ms | 376 KB | Output is correct |
39 | Correct | 5 ms | 376 KB | Output is correct |
40 | Correct | 5 ms | 376 KB | Output is correct |
41 | Correct | 5 ms | 376 KB | Output is correct |
42 | Correct | 5 ms | 376 KB | Output is correct |
43 | Correct | 5 ms | 376 KB | Output is correct |
44 | Correct | 5 ms | 380 KB | Output is correct |
45 | Correct | 5 ms | 376 KB | Output is correct |
46 | Correct | 5 ms | 376 KB | Output is correct |
47 | Correct | 5 ms | 376 KB | Output is correct |
48 | Correct | 5 ms | 376 KB | Output is correct |
49 | Correct | 5 ms | 376 KB | Output is correct |
50 | Correct | 5 ms | 376 KB | Output is correct |
51 | Correct | 5 ms | 376 KB | Output is correct |
52 | Correct | 5 ms | 376 KB | Output is correct |
53 | Correct | 5 ms | 508 KB | Output is correct |
54 | Correct | 5 ms | 504 KB | Output is correct |
55 | Correct | 5 ms | 376 KB | Output is correct |
56 | Correct | 6 ms | 376 KB | Output is correct |
57 | Correct | 6 ms | 504 KB | Output is correct |
58 | Correct | 6 ms | 508 KB | Output is correct |
59 | Correct | 6 ms | 380 KB | Output is correct |
60 | Correct | 6 ms | 376 KB | Output is correct |
61 | Correct | 5 ms | 504 KB | Output is correct |
62 | Correct | 6 ms | 504 KB | Output is correct |
63 | Correct | 5 ms | 376 KB | Output is correct |
64 | Correct | 6 ms | 376 KB | Output is correct |
65 | Correct | 44 ms | 4344 KB | Output is correct |
66 | Correct | 65 ms | 4984 KB | Output is correct |
67 | Correct | 65 ms | 4216 KB | Output is correct |
68 | Correct | 75 ms | 4088 KB | Output is correct |
69 | Correct | 24 ms | 3576 KB | Output is correct |
70 | Correct | 28 ms | 3580 KB | Output is correct |
71 | Correct | 28 ms | 3192 KB | Output is correct |
72 | Correct | 28 ms | 2552 KB | Output is correct |
73 | Correct | 32 ms | 3576 KB | Output is correct |
74 | Correct | 32 ms | 3192 KB | Output is correct |
75 | Correct | 32 ms | 2808 KB | Output is correct |
76 | Correct | 32 ms | 2296 KB | Output is correct |
77 | Correct | 98 ms | 14584 KB | Output is correct |
78 | Correct | 109 ms | 13180 KB | Output is correct |
79 | Correct | 157 ms | 13176 KB | Output is correct |
80 | Correct | 156 ms | 10104 KB | Output is correct |
81 | Correct | 180 ms | 10488 KB | Output is correct |
82 | Correct | 192 ms | 10104 KB | Output is correct |
83 | Correct | 196 ms | 7544 KB | Output is correct |
84 | Correct | 165 ms | 6520 KB | Output is correct |
85 | Correct | 54 ms | 7800 KB | Output is correct |
86 | Correct | 64 ms | 7800 KB | Output is correct |
87 | Correct | 64 ms | 7032 KB | Output is correct |
88 | Correct | 65 ms | 5496 KB | Output is correct |
89 | Correct | 81 ms | 7892 KB | Output is correct |
90 | Correct | 73 ms | 7032 KB | Output is correct |
91 | Correct | 71 ms | 6136 KB | Output is correct |
92 | Correct | 73 ms | 5112 KB | Output is correct |
93 | Runtime error | 8 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
94 | Halted | 0 ms | 0 KB | - |