답안 #579552

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
579552 2022-06-19T11:16:53 Z amunduzbaev Amusement Park (CEOI19_amusementpark) C++17
63 / 100
3000 ms 28872 KB
#include "bits/stdc++.h"
using namespace std;
 
#define ar array
typedef int64_t ll;
//~ #define int ll

const int mod = 119 << 23 | 1;
const int N = 18;
map<int, int> dp[1 << N];
int is[N];

int bp(int a, int b){
	int c = 1;
	while(b){
		if(b & 1) c = c * 1ll * a % mod;
		a = a * 1ll * a % mod, b >>= 1;
	} return c;
}

signed main(){
	ios::sync_with_stdio(0); cin.tie(0);
	
	int n, m; cin>>n>>m;
	for(int i=0;i<m;i++){
		int a, b; cin>>a>>b;
		--a, --b;
		is[a] |= (1 << b);
		is[b] |= (1 << a);
	}
	
	dp[0][0] = 1;
	int tot = (1 << n) - 1;
	for(int mask=0;mask <= tot;mask++){
		for(int j=0;j<n;j++){
			if(mask >> j & 1) continue;
			int cur = (1 << j) - 1;
			int on_j = mask | (1 << j);
			for(int m2=on_j;m2 <= tot; m2++, m2 |= on_j){
				int bad = m2 ^ on_j;
				if(!dp[mask].count(bad)) continue;
				int edge_out = tot ^ (is[j] ^ (is[j] & mask));
				int bad2 = ((bad | cur) ^ (mask & cur)) & edge_out;
				dp[on_j][bad2] = (dp[on_j][bad2] + dp[mask][bad]) % mod;
			}
		}
	}
	
	int res = dp[(1 << n) - 1][0];
	//~ cout<<res<<"\n";
	cout<<res * 1ll * bp(2, mod - 2) % mod * m % mod<<"\n";
}
 
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 12500 KB Output is correct
2 Correct 9 ms 12628 KB Output is correct
3 Correct 7 ms 12628 KB Output is correct
4 Correct 6 ms 12500 KB Output is correct
5 Correct 6 ms 12512 KB Output is correct
6 Correct 7 ms 12588 KB Output is correct
7 Correct 6 ms 12628 KB Output is correct
8 Correct 7 ms 12628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 12500 KB Output is correct
2 Correct 9 ms 12628 KB Output is correct
3 Correct 7 ms 12628 KB Output is correct
4 Correct 6 ms 12500 KB Output is correct
5 Correct 6 ms 12512 KB Output is correct
6 Correct 7 ms 12588 KB Output is correct
7 Correct 6 ms 12628 KB Output is correct
8 Correct 7 ms 12628 KB Output is correct
9 Correct 7 ms 12628 KB Output is correct
10 Correct 7 ms 12628 KB Output is correct
11 Correct 6 ms 12500 KB Output is correct
12 Correct 7 ms 12628 KB Output is correct
13 Correct 8 ms 12628 KB Output is correct
14 Correct 8 ms 12500 KB Output is correct
15 Correct 7 ms 12628 KB Output is correct
16 Correct 7 ms 12628 KB Output is correct
17 Correct 6 ms 12628 KB Output is correct
18 Correct 7 ms 12636 KB Output is correct
19 Correct 6 ms 12628 KB Output is correct
20 Correct 6 ms 12596 KB Output is correct
21 Correct 6 ms 12628 KB Output is correct
22 Correct 7 ms 12628 KB Output is correct
23 Correct 7 ms 12628 KB Output is correct
24 Correct 7 ms 12628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 12500 KB Output is correct
2 Correct 9 ms 12628 KB Output is correct
3 Correct 7 ms 12628 KB Output is correct
4 Correct 6 ms 12500 KB Output is correct
5 Correct 6 ms 12512 KB Output is correct
6 Correct 7 ms 12588 KB Output is correct
7 Correct 6 ms 12628 KB Output is correct
8 Correct 7 ms 12628 KB Output is correct
9 Correct 7 ms 12628 KB Output is correct
10 Correct 7 ms 12628 KB Output is correct
11 Correct 6 ms 12500 KB Output is correct
12 Correct 7 ms 12628 KB Output is correct
13 Correct 8 ms 12628 KB Output is correct
14 Correct 8 ms 12500 KB Output is correct
15 Correct 7 ms 12628 KB Output is correct
16 Correct 7 ms 12628 KB Output is correct
17 Correct 6 ms 12628 KB Output is correct
18 Correct 7 ms 12636 KB Output is correct
19 Correct 6 ms 12628 KB Output is correct
20 Correct 6 ms 12596 KB Output is correct
21 Correct 6 ms 12628 KB Output is correct
22 Correct 7 ms 12628 KB Output is correct
23 Correct 7 ms 12628 KB Output is correct
24 Correct 7 ms 12628 KB Output is correct
25 Correct 6 ms 12628 KB Output is correct
26 Correct 8 ms 12628 KB Output is correct
27 Correct 7 ms 12628 KB Output is correct
28 Correct 7 ms 12628 KB Output is correct
29 Correct 9 ms 12612 KB Output is correct
30 Correct 7 ms 12628 KB Output is correct
31 Correct 8 ms 12628 KB Output is correct
32 Correct 6 ms 12628 KB Output is correct
33 Correct 7 ms 12628 KB Output is correct
34 Correct 7 ms 12628 KB Output is correct
35 Correct 7 ms 12628 KB Output is correct
36 Correct 6 ms 12628 KB Output is correct
37 Correct 7 ms 12544 KB Output is correct
38 Correct 7 ms 12628 KB Output is correct
39 Correct 7 ms 12628 KB Output is correct
40 Correct 7 ms 12628 KB Output is correct
41 Correct 7 ms 12628 KB Output is correct
42 Correct 7 ms 12628 KB Output is correct
43 Correct 8 ms 12628 KB Output is correct
44 Correct 7 ms 12628 KB Output is correct
45 Correct 8 ms 12688 KB Output is correct
46 Correct 9 ms 12668 KB Output is correct
47 Correct 8 ms 12652 KB Output is correct
48 Correct 9 ms 12628 KB Output is correct
49 Correct 7 ms 12628 KB Output is correct
50 Correct 9 ms 12628 KB Output is correct
51 Correct 7 ms 12628 KB Output is correct
52 Correct 10 ms 12708 KB Output is correct
53 Correct 8 ms 12628 KB Output is correct
54 Correct 8 ms 12628 KB Output is correct
55 Correct 7 ms 12628 KB Output is correct
56 Correct 12 ms 12816 KB Output is correct
57 Correct 10 ms 12756 KB Output is correct
58 Correct 8 ms 12628 KB Output is correct
59 Correct 11 ms 12628 KB Output is correct
60 Correct 9 ms 12628 KB Output is correct
61 Correct 8 ms 12628 KB Output is correct
62 Correct 8 ms 12628 KB Output is correct
63 Correct 8 ms 12628 KB Output is correct
64 Correct 8 ms 12628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 12500 KB Output is correct
2 Correct 9 ms 12628 KB Output is correct
3 Correct 7 ms 12628 KB Output is correct
4 Correct 6 ms 12500 KB Output is correct
5 Correct 6 ms 12512 KB Output is correct
6 Correct 7 ms 12588 KB Output is correct
7 Correct 6 ms 12628 KB Output is correct
8 Correct 7 ms 12628 KB Output is correct
9 Correct 7 ms 12628 KB Output is correct
10 Correct 7 ms 12628 KB Output is correct
11 Correct 6 ms 12500 KB Output is correct
12 Correct 7 ms 12628 KB Output is correct
13 Correct 8 ms 12628 KB Output is correct
14 Correct 8 ms 12500 KB Output is correct
15 Correct 7 ms 12628 KB Output is correct
16 Correct 7 ms 12628 KB Output is correct
17 Correct 6 ms 12628 KB Output is correct
18 Correct 7 ms 12636 KB Output is correct
19 Correct 6 ms 12628 KB Output is correct
20 Correct 6 ms 12596 KB Output is correct
21 Correct 6 ms 12628 KB Output is correct
22 Correct 7 ms 12628 KB Output is correct
23 Correct 7 ms 12628 KB Output is correct
24 Correct 7 ms 12628 KB Output is correct
25 Correct 6 ms 12628 KB Output is correct
26 Correct 8 ms 12628 KB Output is correct
27 Correct 7 ms 12628 KB Output is correct
28 Correct 7 ms 12628 KB Output is correct
29 Correct 9 ms 12612 KB Output is correct
30 Correct 7 ms 12628 KB Output is correct
31 Correct 8 ms 12628 KB Output is correct
32 Correct 6 ms 12628 KB Output is correct
33 Correct 7 ms 12628 KB Output is correct
34 Correct 7 ms 12628 KB Output is correct
35 Correct 7 ms 12628 KB Output is correct
36 Correct 6 ms 12628 KB Output is correct
37 Correct 7 ms 12544 KB Output is correct
38 Correct 7 ms 12628 KB Output is correct
39 Correct 7 ms 12628 KB Output is correct
40 Correct 7 ms 12628 KB Output is correct
41 Correct 7 ms 12628 KB Output is correct
42 Correct 7 ms 12628 KB Output is correct
43 Correct 8 ms 12628 KB Output is correct
44 Correct 7 ms 12628 KB Output is correct
45 Correct 8 ms 12688 KB Output is correct
46 Correct 9 ms 12668 KB Output is correct
47 Correct 8 ms 12652 KB Output is correct
48 Correct 9 ms 12628 KB Output is correct
49 Correct 7 ms 12628 KB Output is correct
50 Correct 9 ms 12628 KB Output is correct
51 Correct 7 ms 12628 KB Output is correct
52 Correct 10 ms 12708 KB Output is correct
53 Correct 8 ms 12628 KB Output is correct
54 Correct 8 ms 12628 KB Output is correct
55 Correct 7 ms 12628 KB Output is correct
56 Correct 12 ms 12816 KB Output is correct
57 Correct 10 ms 12756 KB Output is correct
58 Correct 8 ms 12628 KB Output is correct
59 Correct 11 ms 12628 KB Output is correct
60 Correct 9 ms 12628 KB Output is correct
61 Correct 8 ms 12628 KB Output is correct
62 Correct 8 ms 12628 KB Output is correct
63 Correct 8 ms 12628 KB Output is correct
64 Correct 8 ms 12628 KB Output is correct
65 Correct 107 ms 17204 KB Output is correct
66 Correct 138 ms 18800 KB Output is correct
67 Correct 129 ms 18256 KB Output is correct
68 Correct 156 ms 17964 KB Output is correct
69 Correct 67 ms 14528 KB Output is correct
70 Correct 71 ms 14868 KB Output is correct
71 Correct 83 ms 14892 KB Output is correct
72 Correct 97 ms 14924 KB Output is correct
73 Correct 91 ms 14952 KB Output is correct
74 Correct 79 ms 15052 KB Output is correct
75 Correct 81 ms 15084 KB Output is correct
76 Correct 80 ms 15052 KB Output is correct
77 Correct 317 ms 23736 KB Output is correct
78 Correct 370 ms 25040 KB Output is correct
79 Correct 401 ms 28168 KB Output is correct
80 Correct 410 ms 25360 KB Output is correct
81 Correct 390 ms 26800 KB Output is correct
82 Correct 397 ms 25300 KB Output is correct
83 Correct 367 ms 24768 KB Output is correct
84 Correct 354 ms 21232 KB Output is correct
85 Correct 199 ms 16572 KB Output is correct
86 Correct 302 ms 17664 KB Output is correct
87 Correct 239 ms 17516 KB Output is correct
88 Correct 223 ms 17532 KB Output is correct
89 Correct 292 ms 17828 KB Output is correct
90 Correct 238 ms 17724 KB Output is correct
91 Correct 238 ms 17800 KB Output is correct
92 Correct 289 ms 17824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 12500 KB Output is correct
2 Correct 9 ms 12628 KB Output is correct
3 Correct 7 ms 12628 KB Output is correct
4 Correct 6 ms 12500 KB Output is correct
5 Correct 6 ms 12512 KB Output is correct
6 Correct 7 ms 12588 KB Output is correct
7 Correct 6 ms 12628 KB Output is correct
8 Correct 7 ms 12628 KB Output is correct
9 Correct 7 ms 12628 KB Output is correct
10 Correct 7 ms 12628 KB Output is correct
11 Correct 6 ms 12500 KB Output is correct
12 Correct 7 ms 12628 KB Output is correct
13 Correct 8 ms 12628 KB Output is correct
14 Correct 8 ms 12500 KB Output is correct
15 Correct 7 ms 12628 KB Output is correct
16 Correct 7 ms 12628 KB Output is correct
17 Correct 6 ms 12628 KB Output is correct
18 Correct 7 ms 12636 KB Output is correct
19 Correct 6 ms 12628 KB Output is correct
20 Correct 6 ms 12596 KB Output is correct
21 Correct 6 ms 12628 KB Output is correct
22 Correct 7 ms 12628 KB Output is correct
23 Correct 7 ms 12628 KB Output is correct
24 Correct 7 ms 12628 KB Output is correct
25 Correct 6 ms 12628 KB Output is correct
26 Correct 8 ms 12628 KB Output is correct
27 Correct 7 ms 12628 KB Output is correct
28 Correct 7 ms 12628 KB Output is correct
29 Correct 9 ms 12612 KB Output is correct
30 Correct 7 ms 12628 KB Output is correct
31 Correct 8 ms 12628 KB Output is correct
32 Correct 6 ms 12628 KB Output is correct
33 Correct 7 ms 12628 KB Output is correct
34 Correct 7 ms 12628 KB Output is correct
35 Correct 7 ms 12628 KB Output is correct
36 Correct 6 ms 12628 KB Output is correct
37 Correct 7 ms 12544 KB Output is correct
38 Correct 7 ms 12628 KB Output is correct
39 Correct 7 ms 12628 KB Output is correct
40 Correct 7 ms 12628 KB Output is correct
41 Correct 7 ms 12628 KB Output is correct
42 Correct 7 ms 12628 KB Output is correct
43 Correct 8 ms 12628 KB Output is correct
44 Correct 7 ms 12628 KB Output is correct
45 Correct 8 ms 12688 KB Output is correct
46 Correct 9 ms 12668 KB Output is correct
47 Correct 8 ms 12652 KB Output is correct
48 Correct 9 ms 12628 KB Output is correct
49 Correct 7 ms 12628 KB Output is correct
50 Correct 9 ms 12628 KB Output is correct
51 Correct 7 ms 12628 KB Output is correct
52 Correct 10 ms 12708 KB Output is correct
53 Correct 8 ms 12628 KB Output is correct
54 Correct 8 ms 12628 KB Output is correct
55 Correct 7 ms 12628 KB Output is correct
56 Correct 12 ms 12816 KB Output is correct
57 Correct 10 ms 12756 KB Output is correct
58 Correct 8 ms 12628 KB Output is correct
59 Correct 11 ms 12628 KB Output is correct
60 Correct 9 ms 12628 KB Output is correct
61 Correct 8 ms 12628 KB Output is correct
62 Correct 8 ms 12628 KB Output is correct
63 Correct 8 ms 12628 KB Output is correct
64 Correct 8 ms 12628 KB Output is correct
65 Correct 107 ms 17204 KB Output is correct
66 Correct 138 ms 18800 KB Output is correct
67 Correct 129 ms 18256 KB Output is correct
68 Correct 156 ms 17964 KB Output is correct
69 Correct 67 ms 14528 KB Output is correct
70 Correct 71 ms 14868 KB Output is correct
71 Correct 83 ms 14892 KB Output is correct
72 Correct 97 ms 14924 KB Output is correct
73 Correct 91 ms 14952 KB Output is correct
74 Correct 79 ms 15052 KB Output is correct
75 Correct 81 ms 15084 KB Output is correct
76 Correct 80 ms 15052 KB Output is correct
77 Correct 317 ms 23736 KB Output is correct
78 Correct 370 ms 25040 KB Output is correct
79 Correct 401 ms 28168 KB Output is correct
80 Correct 410 ms 25360 KB Output is correct
81 Correct 390 ms 26800 KB Output is correct
82 Correct 397 ms 25300 KB Output is correct
83 Correct 367 ms 24768 KB Output is correct
84 Correct 354 ms 21232 KB Output is correct
85 Correct 199 ms 16572 KB Output is correct
86 Correct 302 ms 17664 KB Output is correct
87 Correct 239 ms 17516 KB Output is correct
88 Correct 223 ms 17532 KB Output is correct
89 Correct 292 ms 17828 KB Output is correct
90 Correct 238 ms 17724 KB Output is correct
91 Correct 238 ms 17800 KB Output is correct
92 Correct 289 ms 17824 KB Output is correct
93 Execution timed out 3069 ms 28872 KB Time limit exceeded
94 Halted 0 ms 0 KB -