Submission #208160

# Submission time Handle Problem Language Result Execution time Memory
208160 2020-03-10T06:39:08 Z E869120 Amusement Park (CEOI19_amusementpark) C++14
63 / 100
160 ms 14588 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], col[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 val = 0;
		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] - val;
			for (int k : X[j]) { if ((col[k] == 1 && k < j) || col[k] == 0) ret += power3[k]; }
			dp[ret] += dp[i]; val += power3[j];
			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

amusementpark.cpp:5:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning (disable: 4996)
 
amusementpark.cpp: In function 'int main()':
amusementpark.cpp:42:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  if (val % 2 == 1) val += mod; val /= 2LL;
  ^~
amusementpark.cpp:42:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  if (val % 2 == 1) val += mod; val /= 2LL;
                                ^~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 5 ms 396 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 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 4 ms 376 KB Output is correct
3 Correct 5 ms 396 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 6 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 5 ms 380 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 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 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 5 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 4 ms 376 KB Output is correct
3 Correct 5 ms 396 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 6 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 5 ms 380 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 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 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 5 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 6 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 380 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 376 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 504 KB Output is correct
54 Correct 5 ms 376 KB Output is correct
55 Correct 5 ms 504 KB Output is correct
56 Correct 6 ms 504 KB Output is correct
57 Correct 6 ms 504 KB Output is correct
58 Correct 6 ms 504 KB Output is correct
59 Correct 6 ms 376 KB Output is correct
60 Correct 5 ms 376 KB Output is correct
61 Correct 5 ms 376 KB Output is correct
62 Correct 5 ms 504 KB Output is correct
63 Correct 5 ms 376 KB Output is correct
64 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 4 ms 376 KB Output is correct
3 Correct 5 ms 396 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 6 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 5 ms 380 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 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 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 5 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 6 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 380 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 376 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 504 KB Output is correct
54 Correct 5 ms 376 KB Output is correct
55 Correct 5 ms 504 KB Output is correct
56 Correct 6 ms 504 KB Output is correct
57 Correct 6 ms 504 KB Output is correct
58 Correct 6 ms 504 KB Output is correct
59 Correct 6 ms 376 KB Output is correct
60 Correct 5 ms 376 KB Output is correct
61 Correct 5 ms 376 KB Output is correct
62 Correct 5 ms 504 KB Output is correct
63 Correct 5 ms 376 KB Output is correct
64 Correct 5 ms 376 KB Output is correct
65 Correct 33 ms 4348 KB Output is correct
66 Correct 50 ms 4984 KB Output is correct
67 Correct 52 ms 4088 KB Output is correct
68 Correct 59 ms 4088 KB Output is correct
69 Correct 19 ms 3576 KB Output is correct
70 Correct 23 ms 3576 KB Output is correct
71 Correct 22 ms 3192 KB Output is correct
72 Correct 21 ms 2556 KB Output is correct
73 Correct 26 ms 3576 KB Output is correct
74 Correct 27 ms 3392 KB Output is correct
75 Correct 24 ms 2808 KB Output is correct
76 Correct 24 ms 2296 KB Output is correct
77 Correct 75 ms 14588 KB Output is correct
78 Correct 87 ms 13176 KB Output is correct
79 Correct 119 ms 13176 KB Output is correct
80 Correct 119 ms 10232 KB Output is correct
81 Correct 142 ms 10488 KB Output is correct
82 Correct 144 ms 10232 KB Output is correct
83 Correct 160 ms 7416 KB Output is correct
84 Correct 133 ms 6384 KB Output is correct
85 Correct 43 ms 7672 KB Output is correct
86 Correct 54 ms 7672 KB Output is correct
87 Correct 49 ms 7032 KB Output is correct
88 Correct 49 ms 5496 KB Output is correct
89 Correct 58 ms 7672 KB Output is correct
90 Correct 62 ms 6908 KB Output is correct
91 Correct 55 ms 6136 KB Output is correct
92 Correct 56 ms 5112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 5 ms 396 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 6 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 5 ms 380 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 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 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 5 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 6 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 380 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 376 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 504 KB Output is correct
54 Correct 5 ms 376 KB Output is correct
55 Correct 5 ms 504 KB Output is correct
56 Correct 6 ms 504 KB Output is correct
57 Correct 6 ms 504 KB Output is correct
58 Correct 6 ms 504 KB Output is correct
59 Correct 6 ms 376 KB Output is correct
60 Correct 5 ms 376 KB Output is correct
61 Correct 5 ms 376 KB Output is correct
62 Correct 5 ms 504 KB Output is correct
63 Correct 5 ms 376 KB Output is correct
64 Correct 5 ms 376 KB Output is correct
65 Correct 33 ms 4348 KB Output is correct
66 Correct 50 ms 4984 KB Output is correct
67 Correct 52 ms 4088 KB Output is correct
68 Correct 59 ms 4088 KB Output is correct
69 Correct 19 ms 3576 KB Output is correct
70 Correct 23 ms 3576 KB Output is correct
71 Correct 22 ms 3192 KB Output is correct
72 Correct 21 ms 2556 KB Output is correct
73 Correct 26 ms 3576 KB Output is correct
74 Correct 27 ms 3392 KB Output is correct
75 Correct 24 ms 2808 KB Output is correct
76 Correct 24 ms 2296 KB Output is correct
77 Correct 75 ms 14588 KB Output is correct
78 Correct 87 ms 13176 KB Output is correct
79 Correct 119 ms 13176 KB Output is correct
80 Correct 119 ms 10232 KB Output is correct
81 Correct 142 ms 10488 KB Output is correct
82 Correct 144 ms 10232 KB Output is correct
83 Correct 160 ms 7416 KB Output is correct
84 Correct 133 ms 6384 KB Output is correct
85 Correct 43 ms 7672 KB Output is correct
86 Correct 54 ms 7672 KB Output is correct
87 Correct 49 ms 7032 KB Output is correct
88 Correct 49 ms 5496 KB Output is correct
89 Correct 58 ms 7672 KB Output is correct
90 Correct 62 ms 6908 KB Output is correct
91 Correct 55 ms 6136 KB Output is correct
92 Correct 56 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 -