답안 #579553

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
579553 2022-06-19T11:18:47 Z amunduzbaev Amusement Park (CEOI19_amusementpark) C++17
63 / 100
3000 ms 29948 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;
unordered_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;
	for(int mask=0;mask < (1 << n);mask++){
		for(int j=0;j<n;j++){
			if(mask >> j & 1) continue;
			
			int on_j = mask | (1 << j);
			for(int m2=on_j;m2 < (1 << n); m2++, m2 |= on_j){
				int bad = m2 ^ on_j;
				if(!dp[mask].count(bad)) continue;
				int edge_out = ((1 << n) - 1) ^ (is[j] ^ (is[j] & mask));
				int bad2 = ((bad | ((1 << j) - 1)) ^ (mask & ((1 << j) - 1))) & 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 8 ms 14676 KB Output is correct
2 Correct 9 ms 14588 KB Output is correct
3 Correct 10 ms 14676 KB Output is correct
4 Correct 9 ms 14676 KB Output is correct
5 Correct 8 ms 14676 KB Output is correct
6 Correct 11 ms 14612 KB Output is correct
7 Correct 10 ms 14572 KB Output is correct
8 Correct 11 ms 14676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14676 KB Output is correct
2 Correct 9 ms 14588 KB Output is correct
3 Correct 10 ms 14676 KB Output is correct
4 Correct 9 ms 14676 KB Output is correct
5 Correct 8 ms 14676 KB Output is correct
6 Correct 11 ms 14612 KB Output is correct
7 Correct 10 ms 14572 KB Output is correct
8 Correct 11 ms 14676 KB Output is correct
9 Correct 10 ms 14604 KB Output is correct
10 Correct 8 ms 14676 KB Output is correct
11 Correct 9 ms 14688 KB Output is correct
12 Correct 9 ms 14676 KB Output is correct
13 Correct 8 ms 14676 KB Output is correct
14 Correct 11 ms 14680 KB Output is correct
15 Correct 10 ms 14676 KB Output is correct
16 Correct 9 ms 14676 KB Output is correct
17 Correct 9 ms 14676 KB Output is correct
18 Correct 9 ms 14676 KB Output is correct
19 Correct 9 ms 14660 KB Output is correct
20 Correct 9 ms 14664 KB Output is correct
21 Correct 10 ms 14676 KB Output is correct
22 Correct 12 ms 14676 KB Output is correct
23 Correct 8 ms 14676 KB Output is correct
24 Correct 8 ms 14600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14676 KB Output is correct
2 Correct 9 ms 14588 KB Output is correct
3 Correct 10 ms 14676 KB Output is correct
4 Correct 9 ms 14676 KB Output is correct
5 Correct 8 ms 14676 KB Output is correct
6 Correct 11 ms 14612 KB Output is correct
7 Correct 10 ms 14572 KB Output is correct
8 Correct 11 ms 14676 KB Output is correct
9 Correct 10 ms 14604 KB Output is correct
10 Correct 8 ms 14676 KB Output is correct
11 Correct 9 ms 14688 KB Output is correct
12 Correct 9 ms 14676 KB Output is correct
13 Correct 8 ms 14676 KB Output is correct
14 Correct 11 ms 14680 KB Output is correct
15 Correct 10 ms 14676 KB Output is correct
16 Correct 9 ms 14676 KB Output is correct
17 Correct 9 ms 14676 KB Output is correct
18 Correct 9 ms 14676 KB Output is correct
19 Correct 9 ms 14660 KB Output is correct
20 Correct 9 ms 14664 KB Output is correct
21 Correct 10 ms 14676 KB Output is correct
22 Correct 12 ms 14676 KB Output is correct
23 Correct 8 ms 14676 KB Output is correct
24 Correct 8 ms 14600 KB Output is correct
25 Correct 9 ms 14644 KB Output is correct
26 Correct 10 ms 14616 KB Output is correct
27 Correct 10 ms 14680 KB Output is correct
28 Correct 8 ms 14688 KB Output is correct
29 Correct 12 ms 14700 KB Output is correct
30 Correct 8 ms 14676 KB Output is correct
31 Correct 11 ms 14700 KB Output is correct
32 Correct 9 ms 14664 KB Output is correct
33 Correct 9 ms 14676 KB Output is correct
34 Correct 9 ms 14728 KB Output is correct
35 Correct 9 ms 14692 KB Output is correct
36 Correct 9 ms 14720 KB Output is correct
37 Correct 9 ms 14672 KB Output is correct
38 Correct 9 ms 14676 KB Output is correct
39 Correct 11 ms 14676 KB Output is correct
40 Correct 9 ms 14676 KB Output is correct
41 Correct 11 ms 14676 KB Output is correct
42 Correct 13 ms 14676 KB Output is correct
43 Correct 10 ms 14676 KB Output is correct
44 Correct 10 ms 14676 KB Output is correct
45 Correct 12 ms 14776 KB Output is correct
46 Correct 10 ms 14676 KB Output is correct
47 Correct 10 ms 14676 KB Output is correct
48 Correct 8 ms 14656 KB Output is correct
49 Correct 9 ms 14676 KB Output is correct
50 Correct 9 ms 14676 KB Output is correct
51 Correct 9 ms 14676 KB Output is correct
52 Correct 12 ms 14804 KB Output is correct
53 Correct 11 ms 14804 KB Output is correct
54 Correct 11 ms 14804 KB Output is correct
55 Correct 13 ms 14868 KB Output is correct
56 Correct 15 ms 15024 KB Output is correct
57 Correct 15 ms 14820 KB Output is correct
58 Correct 13 ms 14860 KB Output is correct
59 Correct 10 ms 14804 KB Output is correct
60 Correct 10 ms 14804 KB Output is correct
61 Correct 10 ms 14804 KB Output is correct
62 Correct 11 ms 14804 KB Output is correct
63 Correct 11 ms 14804 KB Output is correct
64 Correct 10 ms 14804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14676 KB Output is correct
2 Correct 9 ms 14588 KB Output is correct
3 Correct 10 ms 14676 KB Output is correct
4 Correct 9 ms 14676 KB Output is correct
5 Correct 8 ms 14676 KB Output is correct
6 Correct 11 ms 14612 KB Output is correct
7 Correct 10 ms 14572 KB Output is correct
8 Correct 11 ms 14676 KB Output is correct
9 Correct 10 ms 14604 KB Output is correct
10 Correct 8 ms 14676 KB Output is correct
11 Correct 9 ms 14688 KB Output is correct
12 Correct 9 ms 14676 KB Output is correct
13 Correct 8 ms 14676 KB Output is correct
14 Correct 11 ms 14680 KB Output is correct
15 Correct 10 ms 14676 KB Output is correct
16 Correct 9 ms 14676 KB Output is correct
17 Correct 9 ms 14676 KB Output is correct
18 Correct 9 ms 14676 KB Output is correct
19 Correct 9 ms 14660 KB Output is correct
20 Correct 9 ms 14664 KB Output is correct
21 Correct 10 ms 14676 KB Output is correct
22 Correct 12 ms 14676 KB Output is correct
23 Correct 8 ms 14676 KB Output is correct
24 Correct 8 ms 14600 KB Output is correct
25 Correct 9 ms 14644 KB Output is correct
26 Correct 10 ms 14616 KB Output is correct
27 Correct 10 ms 14680 KB Output is correct
28 Correct 8 ms 14688 KB Output is correct
29 Correct 12 ms 14700 KB Output is correct
30 Correct 8 ms 14676 KB Output is correct
31 Correct 11 ms 14700 KB Output is correct
32 Correct 9 ms 14664 KB Output is correct
33 Correct 9 ms 14676 KB Output is correct
34 Correct 9 ms 14728 KB Output is correct
35 Correct 9 ms 14692 KB Output is correct
36 Correct 9 ms 14720 KB Output is correct
37 Correct 9 ms 14672 KB Output is correct
38 Correct 9 ms 14676 KB Output is correct
39 Correct 11 ms 14676 KB Output is correct
40 Correct 9 ms 14676 KB Output is correct
41 Correct 11 ms 14676 KB Output is correct
42 Correct 13 ms 14676 KB Output is correct
43 Correct 10 ms 14676 KB Output is correct
44 Correct 10 ms 14676 KB Output is correct
45 Correct 12 ms 14776 KB Output is correct
46 Correct 10 ms 14676 KB Output is correct
47 Correct 10 ms 14676 KB Output is correct
48 Correct 8 ms 14656 KB Output is correct
49 Correct 9 ms 14676 KB Output is correct
50 Correct 9 ms 14676 KB Output is correct
51 Correct 9 ms 14676 KB Output is correct
52 Correct 12 ms 14804 KB Output is correct
53 Correct 11 ms 14804 KB Output is correct
54 Correct 11 ms 14804 KB Output is correct
55 Correct 13 ms 14868 KB Output is correct
56 Correct 15 ms 15024 KB Output is correct
57 Correct 15 ms 14820 KB Output is correct
58 Correct 13 ms 14860 KB Output is correct
59 Correct 10 ms 14804 KB Output is correct
60 Correct 10 ms 14804 KB Output is correct
61 Correct 10 ms 14804 KB Output is correct
62 Correct 11 ms 14804 KB Output is correct
63 Correct 11 ms 14804 KB Output is correct
64 Correct 10 ms 14804 KB Output is correct
65 Correct 271 ms 19648 KB Output is correct
66 Correct 281 ms 20644 KB Output is correct
67 Correct 284 ms 20360 KB Output is correct
68 Correct 269 ms 20008 KB Output is correct
69 Correct 226 ms 17752 KB Output is correct
70 Correct 204 ms 17980 KB Output is correct
71 Correct 206 ms 17920 KB Output is correct
72 Correct 195 ms 17996 KB Output is correct
73 Correct 231 ms 18128 KB Output is correct
74 Correct 208 ms 18024 KB Output is correct
75 Correct 229 ms 18044 KB Output is correct
76 Correct 215 ms 18060 KB Output is correct
77 Correct 784 ms 26340 KB Output is correct
78 Correct 770 ms 27180 KB Output is correct
79 Correct 816 ms 29948 KB Output is correct
80 Correct 806 ms 27308 KB Output is correct
81 Correct 860 ms 28400 KB Output is correct
82 Correct 861 ms 27100 KB Output is correct
83 Correct 879 ms 26580 KB Output is correct
84 Correct 793 ms 24072 KB Output is correct
85 Correct 623 ms 20912 KB Output is correct
86 Correct 630 ms 21580 KB Output is correct
87 Correct 624 ms 21580 KB Output is correct
88 Correct 670 ms 21524 KB Output is correct
89 Correct 653 ms 21732 KB Output is correct
90 Correct 656 ms 21744 KB Output is correct
91 Correct 688 ms 21692 KB Output is correct
92 Correct 670 ms 21652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14676 KB Output is correct
2 Correct 9 ms 14588 KB Output is correct
3 Correct 10 ms 14676 KB Output is correct
4 Correct 9 ms 14676 KB Output is correct
5 Correct 8 ms 14676 KB Output is correct
6 Correct 11 ms 14612 KB Output is correct
7 Correct 10 ms 14572 KB Output is correct
8 Correct 11 ms 14676 KB Output is correct
9 Correct 10 ms 14604 KB Output is correct
10 Correct 8 ms 14676 KB Output is correct
11 Correct 9 ms 14688 KB Output is correct
12 Correct 9 ms 14676 KB Output is correct
13 Correct 8 ms 14676 KB Output is correct
14 Correct 11 ms 14680 KB Output is correct
15 Correct 10 ms 14676 KB Output is correct
16 Correct 9 ms 14676 KB Output is correct
17 Correct 9 ms 14676 KB Output is correct
18 Correct 9 ms 14676 KB Output is correct
19 Correct 9 ms 14660 KB Output is correct
20 Correct 9 ms 14664 KB Output is correct
21 Correct 10 ms 14676 KB Output is correct
22 Correct 12 ms 14676 KB Output is correct
23 Correct 8 ms 14676 KB Output is correct
24 Correct 8 ms 14600 KB Output is correct
25 Correct 9 ms 14644 KB Output is correct
26 Correct 10 ms 14616 KB Output is correct
27 Correct 10 ms 14680 KB Output is correct
28 Correct 8 ms 14688 KB Output is correct
29 Correct 12 ms 14700 KB Output is correct
30 Correct 8 ms 14676 KB Output is correct
31 Correct 11 ms 14700 KB Output is correct
32 Correct 9 ms 14664 KB Output is correct
33 Correct 9 ms 14676 KB Output is correct
34 Correct 9 ms 14728 KB Output is correct
35 Correct 9 ms 14692 KB Output is correct
36 Correct 9 ms 14720 KB Output is correct
37 Correct 9 ms 14672 KB Output is correct
38 Correct 9 ms 14676 KB Output is correct
39 Correct 11 ms 14676 KB Output is correct
40 Correct 9 ms 14676 KB Output is correct
41 Correct 11 ms 14676 KB Output is correct
42 Correct 13 ms 14676 KB Output is correct
43 Correct 10 ms 14676 KB Output is correct
44 Correct 10 ms 14676 KB Output is correct
45 Correct 12 ms 14776 KB Output is correct
46 Correct 10 ms 14676 KB Output is correct
47 Correct 10 ms 14676 KB Output is correct
48 Correct 8 ms 14656 KB Output is correct
49 Correct 9 ms 14676 KB Output is correct
50 Correct 9 ms 14676 KB Output is correct
51 Correct 9 ms 14676 KB Output is correct
52 Correct 12 ms 14804 KB Output is correct
53 Correct 11 ms 14804 KB Output is correct
54 Correct 11 ms 14804 KB Output is correct
55 Correct 13 ms 14868 KB Output is correct
56 Correct 15 ms 15024 KB Output is correct
57 Correct 15 ms 14820 KB Output is correct
58 Correct 13 ms 14860 KB Output is correct
59 Correct 10 ms 14804 KB Output is correct
60 Correct 10 ms 14804 KB Output is correct
61 Correct 10 ms 14804 KB Output is correct
62 Correct 11 ms 14804 KB Output is correct
63 Correct 11 ms 14804 KB Output is correct
64 Correct 10 ms 14804 KB Output is correct
65 Correct 271 ms 19648 KB Output is correct
66 Correct 281 ms 20644 KB Output is correct
67 Correct 284 ms 20360 KB Output is correct
68 Correct 269 ms 20008 KB Output is correct
69 Correct 226 ms 17752 KB Output is correct
70 Correct 204 ms 17980 KB Output is correct
71 Correct 206 ms 17920 KB Output is correct
72 Correct 195 ms 17996 KB Output is correct
73 Correct 231 ms 18128 KB Output is correct
74 Correct 208 ms 18024 KB Output is correct
75 Correct 229 ms 18044 KB Output is correct
76 Correct 215 ms 18060 KB Output is correct
77 Correct 784 ms 26340 KB Output is correct
78 Correct 770 ms 27180 KB Output is correct
79 Correct 816 ms 29948 KB Output is correct
80 Correct 806 ms 27308 KB Output is correct
81 Correct 860 ms 28400 KB Output is correct
82 Correct 861 ms 27100 KB Output is correct
83 Correct 879 ms 26580 KB Output is correct
84 Correct 793 ms 24072 KB Output is correct
85 Correct 623 ms 20912 KB Output is correct
86 Correct 630 ms 21580 KB Output is correct
87 Correct 624 ms 21580 KB Output is correct
88 Correct 670 ms 21524 KB Output is correct
89 Correct 653 ms 21732 KB Output is correct
90 Correct 656 ms 21744 KB Output is correct
91 Correct 688 ms 21692 KB Output is correct
92 Correct 670 ms 21652 KB Output is correct
93 Execution timed out 3073 ms 22260 KB Time limit exceeded
94 Halted 0 ms 0 KB -