답안 #208158

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

amusementpark.cpp:5:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning (disable: 4996)
 
amusementpark.cpp: In function 'int main()':
amusementpark.cpp:43:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  if (val % 2 == 1) val += mod; val /= 2LL;
  ^~
amusementpark.cpp:43: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 4 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 4 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 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 4 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 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 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 4 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 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
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 4 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 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 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 4 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 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 4 ms 380 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 380 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 6 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 380 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 504 KB Output is correct
55 Correct 5 ms 376 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 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 6 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 4 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 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 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 4 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 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 4 ms 380 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 380 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 6 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 380 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 504 KB Output is correct
55 Correct 5 ms 376 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 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 6 ms 504 KB Output is correct
65 Correct 43 ms 4344 KB Output is correct
66 Correct 63 ms 4904 KB Output is correct
67 Correct 63 ms 4172 KB Output is correct
68 Correct 74 ms 4088 KB Output is correct
69 Correct 25 ms 3576 KB Output is correct
70 Correct 29 ms 3576 KB Output is correct
71 Correct 27 ms 3192 KB Output is correct
72 Correct 28 ms 2552 KB Output is correct
73 Correct 33 ms 3576 KB Output is correct
74 Correct 32 ms 3192 KB Output is correct
75 Correct 33 ms 2808 KB Output is correct
76 Correct 33 ms 2296 KB Output is correct
77 Correct 93 ms 14584 KB Output is correct
78 Correct 110 ms 13176 KB Output is correct
79 Correct 156 ms 13176 KB Output is correct
80 Correct 156 ms 10072 KB Output is correct
81 Correct 185 ms 10544 KB Output is correct
82 Correct 189 ms 10104 KB Output is correct
83 Correct 199 ms 7544 KB Output is correct
84 Correct 176 ms 6520 KB Output is correct
85 Correct 54 ms 7800 KB Output is correct
86 Correct 66 ms 7800 KB Output is correct
87 Correct 65 ms 7032 KB Output is correct
88 Correct 66 ms 5500 KB Output is correct
89 Correct 75 ms 7776 KB Output is correct
90 Correct 73 ms 7032 KB Output is correct
91 Correct 73 ms 6136 KB Output is correct
92 Correct 74 ms 5112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 4 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 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 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 4 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 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 4 ms 380 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 380 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 6 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 380 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 504 KB Output is correct
55 Correct 5 ms 376 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 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 6 ms 504 KB Output is correct
65 Correct 43 ms 4344 KB Output is correct
66 Correct 63 ms 4904 KB Output is correct
67 Correct 63 ms 4172 KB Output is correct
68 Correct 74 ms 4088 KB Output is correct
69 Correct 25 ms 3576 KB Output is correct
70 Correct 29 ms 3576 KB Output is correct
71 Correct 27 ms 3192 KB Output is correct
72 Correct 28 ms 2552 KB Output is correct
73 Correct 33 ms 3576 KB Output is correct
74 Correct 32 ms 3192 KB Output is correct
75 Correct 33 ms 2808 KB Output is correct
76 Correct 33 ms 2296 KB Output is correct
77 Correct 93 ms 14584 KB Output is correct
78 Correct 110 ms 13176 KB Output is correct
79 Correct 156 ms 13176 KB Output is correct
80 Correct 156 ms 10072 KB Output is correct
81 Correct 185 ms 10544 KB Output is correct
82 Correct 189 ms 10104 KB Output is correct
83 Correct 199 ms 7544 KB Output is correct
84 Correct 176 ms 6520 KB Output is correct
85 Correct 54 ms 7800 KB Output is correct
86 Correct 66 ms 7800 KB Output is correct
87 Correct 65 ms 7032 KB Output is correct
88 Correct 66 ms 5500 KB Output is correct
89 Correct 75 ms 7776 KB Output is correct
90 Correct 73 ms 7032 KB Output is correct
91 Correct 73 ms 6136 KB Output is correct
92 Correct 74 ms 5112 KB Output is correct
93 Correct 1107 ms 80772 KB Output is correct
94 Correct 811 ms 38648 KB Output is correct
95 Correct 764 ms 30584 KB Output is correct
96 Correct 1179 ms 80592 KB Output is correct
97 Correct 1187 ms 80504 KB Output is correct
98 Correct 1065 ms 80632 KB Output is correct
99 Correct 186 ms 33272 KB Output is correct
100 Correct 243 ms 30840 KB Output is correct
101 Correct 335 ms 34168 KB Output is correct
102 Correct 419 ms 30968 KB Output is correct
103 Correct 277 ms 14072 KB Output is correct
104 Correct 286 ms 14328 KB Output is correct
105 Correct 344 ms 46840 KB Output is correct
106 Correct 587 ms 68116 KB Output is correct
107 Correct 754 ms 29048 KB Output is correct
108 Correct 905 ms 84728 KB Output is correct
109 Correct 1448 ms 176336 KB Output is correct
110 Correct 2785 ms 266616 KB Output is correct
111 Correct 489 ms 33752 KB Output is correct
112 Correct 424 ms 16760 KB Output is correct
113 Correct 480 ms 20600 KB Output is correct
114 Correct 135 ms 16760 KB Output is correct
115 Correct 164 ms 16764 KB Output is correct
116 Correct 162 ms 15096 KB Output is correct
117 Correct 154 ms 11896 KB Output is correct
118 Correct 183 ms 16748 KB Output is correct
119 Correct 174 ms 15224 KB Output is correct
120 Correct 182 ms 13592 KB Output is correct
121 Correct 178 ms 11256 KB Output is correct
122 Correct 730 ms 75896 KB Output is correct
123 Correct 1125 ms 85876 KB Output is correct
124 Correct 1162 ms 65272 KB Output is correct
125 Correct 1242 ms 58744 KB Output is correct
126 Correct 1219 ms 49384 KB Output is correct
127 Correct 1060 ms 33272 KB Output is correct
128 Correct 869 ms 24440 KB Output is correct
129 Correct 661 ms 16764 KB Output is correct
130 Correct 414 ms 9848 KB Output is correct
131 Correct 355 ms 36856 KB Output is correct
132 Correct 413 ms 36856 KB Output is correct
133 Correct 393 ms 33656 KB Output is correct
134 Correct 394 ms 26356 KB Output is correct
135 Correct 467 ms 36856 KB Output is correct
136 Correct 434 ms 33656 KB Output is correct
137 Correct 439 ms 30504 KB Output is correct
138 Correct 447 ms 25592 KB Output is correct
139 Correct 511 ms 36524 KB Output is correct
140 Correct 477 ms 29048 KB Output is correct
141 Correct 463 ms 23416 KB Output is correct
142 Correct 2693 ms 167400 KB Output is correct
143 Execution timed out 3095 ms 143700 KB Time limit exceeded
144 Halted 0 ms 0 KB -