답안 #208159

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
208159 2020-03-10T06:37:23 Z E869120 Amusement Park (CEOI19_amusementpark) C++14
63 / 100
3000 ms 266768 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[387420489], 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;

		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

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;
                                ^~~
# 결과 실행 시간 메모리 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 372 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 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 372 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 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 376 KB Output is correct
13 Correct 5 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 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 4 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
# 결과 실행 시간 메모리 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 372 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 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 376 KB Output is correct
13 Correct 5 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 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 4 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 6 ms 376 KB Output is correct
27 Correct 5 ms 380 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 380 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 504 KB Output is correct
42 Correct 5 ms 376 KB Output is correct
43 Correct 6 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 504 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 376 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 504 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
# 결과 실행 시간 메모리 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 372 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 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 376 KB Output is correct
13 Correct 5 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 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 4 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 6 ms 376 KB Output is correct
27 Correct 5 ms 380 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 380 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 504 KB Output is correct
42 Correct 5 ms 376 KB Output is correct
43 Correct 6 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 504 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 376 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 504 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 42 ms 4440 KB Output is correct
66 Correct 63 ms 4988 KB Output is correct
67 Correct 63 ms 4088 KB Output is correct
68 Correct 74 ms 4088 KB Output is correct
69 Correct 22 ms 3576 KB Output is correct
70 Correct 26 ms 3580 KB Output is correct
71 Correct 26 ms 3196 KB Output is correct
72 Correct 26 ms 2552 KB Output is correct
73 Correct 31 ms 3596 KB Output is correct
74 Correct 29 ms 3192 KB Output is correct
75 Correct 30 ms 2808 KB Output is correct
76 Correct 30 ms 2296 KB Output is correct
77 Correct 93 ms 14584 KB Output is correct
78 Correct 106 ms 13176 KB Output is correct
79 Correct 150 ms 13176 KB Output is correct
80 Correct 149 ms 10104 KB Output is correct
81 Correct 178 ms 10488 KB Output is correct
82 Correct 184 ms 10232 KB Output is correct
83 Correct 190 ms 7416 KB Output is correct
84 Correct 156 ms 6396 KB Output is correct
85 Correct 49 ms 7928 KB Output is correct
86 Correct 60 ms 7672 KB Output is correct
87 Correct 59 ms 6904 KB Output is correct
88 Correct 57 ms 5496 KB Output is correct
89 Correct 68 ms 7672 KB Output is correct
90 Correct 68 ms 6904 KB Output is correct
91 Correct 65 ms 6136 KB Output is correct
92 Correct 67 ms 5112 KB Output is correct
# 결과 실행 시간 메모리 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 372 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 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 376 KB Output is correct
13 Correct 5 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 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 4 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 6 ms 376 KB Output is correct
27 Correct 5 ms 380 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 380 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 504 KB Output is correct
42 Correct 5 ms 376 KB Output is correct
43 Correct 6 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 504 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 376 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 504 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 42 ms 4440 KB Output is correct
66 Correct 63 ms 4988 KB Output is correct
67 Correct 63 ms 4088 KB Output is correct
68 Correct 74 ms 4088 KB Output is correct
69 Correct 22 ms 3576 KB Output is correct
70 Correct 26 ms 3580 KB Output is correct
71 Correct 26 ms 3196 KB Output is correct
72 Correct 26 ms 2552 KB Output is correct
73 Correct 31 ms 3596 KB Output is correct
74 Correct 29 ms 3192 KB Output is correct
75 Correct 30 ms 2808 KB Output is correct
76 Correct 30 ms 2296 KB Output is correct
77 Correct 93 ms 14584 KB Output is correct
78 Correct 106 ms 13176 KB Output is correct
79 Correct 150 ms 13176 KB Output is correct
80 Correct 149 ms 10104 KB Output is correct
81 Correct 178 ms 10488 KB Output is correct
82 Correct 184 ms 10232 KB Output is correct
83 Correct 190 ms 7416 KB Output is correct
84 Correct 156 ms 6396 KB Output is correct
85 Correct 49 ms 7928 KB Output is correct
86 Correct 60 ms 7672 KB Output is correct
87 Correct 59 ms 6904 KB Output is correct
88 Correct 57 ms 5496 KB Output is correct
89 Correct 68 ms 7672 KB Output is correct
90 Correct 68 ms 6904 KB Output is correct
91 Correct 65 ms 6136 KB Output is correct
92 Correct 67 ms 5112 KB Output is correct
93 Correct 910 ms 80516 KB Output is correct
94 Correct 664 ms 38776 KB Output is correct
95 Correct 582 ms 30584 KB Output is correct
96 Correct 1066 ms 80632 KB Output is correct
97 Correct 1067 ms 80504 KB Output is correct
98 Correct 908 ms 80632 KB Output is correct
99 Correct 158 ms 33272 KB Output is correct
100 Correct 222 ms 30840 KB Output is correct
101 Correct 330 ms 34296 KB Output is correct
102 Correct 403 ms 30968 KB Output is correct
103 Correct 213 ms 14204 KB Output is correct
104 Correct 210 ms 14200 KB Output is correct
105 Correct 282 ms 46840 KB Output is correct
106 Correct 521 ms 68344 KB Output is correct
107 Correct 582 ms 29048 KB Output is correct
108 Correct 771 ms 84600 KB Output is correct
109 Correct 1280 ms 176376 KB Output is correct
110 Correct 2588 ms 266768 KB Output is correct
111 Correct 459 ms 33656 KB Output is correct
112 Correct 427 ms 16848 KB Output is correct
113 Correct 478 ms 20472 KB Output is correct
114 Correct 122 ms 16888 KB Output is correct
115 Correct 147 ms 16760 KB Output is correct
116 Correct 159 ms 15224 KB Output is correct
117 Correct 143 ms 11896 KB Output is correct
118 Correct 168 ms 16808 KB Output is correct
119 Correct 166 ms 15224 KB Output is correct
120 Correct 165 ms 13560 KB Output is correct
121 Correct 164 ms 11384 KB Output is correct
122 Correct 710 ms 75740 KB Output is correct
123 Correct 1101 ms 85928 KB Output is correct
124 Correct 1146 ms 65400 KB Output is correct
125 Correct 1208 ms 58616 KB Output is correct
126 Correct 1211 ms 49524 KB Output is correct
127 Correct 1022 ms 33272 KB Output is correct
128 Correct 829 ms 24184 KB Output is correct
129 Correct 616 ms 16760 KB Output is correct
130 Correct 372 ms 9792 KB Output is correct
131 Correct 300 ms 36728 KB Output is correct
132 Correct 368 ms 36952 KB Output is correct
133 Correct 360 ms 33528 KB Output is correct
134 Correct 371 ms 26616 KB Output is correct
135 Correct 415 ms 36688 KB Output is correct
136 Correct 396 ms 33656 KB Output is correct
137 Correct 396 ms 30328 KB Output is correct
138 Correct 412 ms 25720 KB Output is correct
139 Correct 453 ms 36472 KB Output is correct
140 Correct 462 ms 29048 KB Output is correct
141 Correct 427 ms 23416 KB Output is correct
142 Correct 2596 ms 167332 KB Output is correct
143 Execution timed out 3068 ms 145232 KB Time limit exceeded
144 Halted 0 ms 0 KB -