답안 #782029

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
782029 2023-07-13T14:52:34 Z Lobo Amusement Park (CEOI19_amusementpark) C++17
100 / 100
1313 ms 223032 KB
#include<bits/stdc++.h>
using namespace std;
const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
const int maxn = 18;
const int mod = 998244353;

int n, m, g[maxn];
unordered_map<int,int> dp[(1<<maxn)];

int opos(int x) {
    return (1<<n)-1-x;
}

void solve() {
    cin >> n >> m;

    for(int i = 1; i <= m; i++) {
        int u,v; cin >> u >> v; u--; v--;
        g[u]+= (1<<v);
        g[v]+= (1<<u);
    }

    dp[0][(1<<n)-1] = 1;
    for(int use = 0; use < (1<<n)-1; use++) {
        for(auto X : dp[use]) {
            int nxt = X.fr;
            int cnt = X.sc;

            for(int i = 0; i < n; i++) {
                if(((1<<i)&nxt) == 0) continue;
                int use1 = use+(1<<i);
                int nxt1 = ((nxt&opos((1<<(i+1))-1))|g[i])&(opos(use1));
                dp[use1][nxt1]+= cnt;
                dp[use1][nxt1]%= mod;
            }
        }
    }

    cout << dp[(1<<n)-1][0]*m%mod*((mod+1)/2)%mod << endl;
}
    
int32_t main() {
    ios::sync_with_stdio(false); cin.tie(0);

    // freopen("in.in", "r", stdin);
    // freopen("out.out", "w", stdout);
    int tt = 1;
    // cin >> tt;
    while(tt--) {
        solve();
    }

}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14804 KB Output is correct
2 Correct 8 ms 14684 KB Output is correct
3 Correct 8 ms 14636 KB Output is correct
4 Correct 8 ms 14592 KB Output is correct
5 Correct 8 ms 14684 KB Output is correct
6 Correct 8 ms 14604 KB Output is correct
7 Correct 8 ms 14688 KB Output is correct
8 Correct 8 ms 14600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14804 KB Output is correct
2 Correct 8 ms 14684 KB Output is correct
3 Correct 8 ms 14636 KB Output is correct
4 Correct 8 ms 14592 KB Output is correct
5 Correct 8 ms 14684 KB Output is correct
6 Correct 8 ms 14604 KB Output is correct
7 Correct 8 ms 14688 KB Output is correct
8 Correct 8 ms 14600 KB Output is correct
9 Correct 8 ms 14684 KB Output is correct
10 Correct 8 ms 14684 KB Output is correct
11 Correct 7 ms 14612 KB Output is correct
12 Correct 7 ms 14676 KB Output is correct
13 Correct 8 ms 14680 KB Output is correct
14 Correct 8 ms 14684 KB Output is correct
15 Correct 7 ms 14676 KB Output is correct
16 Correct 7 ms 14676 KB Output is correct
17 Correct 8 ms 14688 KB Output is correct
18 Correct 8 ms 14640 KB Output is correct
19 Correct 8 ms 14680 KB Output is correct
20 Correct 9 ms 14676 KB Output is correct
21 Correct 8 ms 14676 KB Output is correct
22 Correct 9 ms 14676 KB Output is correct
23 Correct 7 ms 14684 KB Output is correct
24 Correct 8 ms 14676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14804 KB Output is correct
2 Correct 8 ms 14684 KB Output is correct
3 Correct 8 ms 14636 KB Output is correct
4 Correct 8 ms 14592 KB Output is correct
5 Correct 8 ms 14684 KB Output is correct
6 Correct 8 ms 14604 KB Output is correct
7 Correct 8 ms 14688 KB Output is correct
8 Correct 8 ms 14600 KB Output is correct
9 Correct 8 ms 14684 KB Output is correct
10 Correct 8 ms 14684 KB Output is correct
11 Correct 7 ms 14612 KB Output is correct
12 Correct 7 ms 14676 KB Output is correct
13 Correct 8 ms 14680 KB Output is correct
14 Correct 8 ms 14684 KB Output is correct
15 Correct 7 ms 14676 KB Output is correct
16 Correct 7 ms 14676 KB Output is correct
17 Correct 8 ms 14688 KB Output is correct
18 Correct 8 ms 14640 KB Output is correct
19 Correct 8 ms 14680 KB Output is correct
20 Correct 9 ms 14676 KB Output is correct
21 Correct 8 ms 14676 KB Output is correct
22 Correct 9 ms 14676 KB Output is correct
23 Correct 7 ms 14684 KB Output is correct
24 Correct 8 ms 14676 KB Output is correct
25 Correct 9 ms 14676 KB Output is correct
26 Correct 8 ms 14680 KB Output is correct
27 Correct 7 ms 14680 KB Output is correct
28 Correct 8 ms 14680 KB Output is correct
29 Correct 8 ms 14688 KB Output is correct
30 Correct 10 ms 14676 KB Output is correct
31 Correct 9 ms 14616 KB Output is correct
32 Correct 8 ms 14624 KB Output is correct
33 Correct 9 ms 14688 KB Output is correct
34 Correct 13 ms 14676 KB Output is correct
35 Correct 8 ms 14684 KB Output is correct
36 Correct 10 ms 14668 KB Output is correct
37 Correct 8 ms 14676 KB Output is correct
38 Correct 8 ms 14688 KB Output is correct
39 Correct 9 ms 14684 KB Output is correct
40 Correct 9 ms 14676 KB Output is correct
41 Correct 11 ms 14776 KB Output is correct
42 Correct 11 ms 14676 KB Output is correct
43 Correct 13 ms 14676 KB Output is correct
44 Correct 13 ms 14684 KB Output is correct
45 Correct 8 ms 14676 KB Output is correct
46 Correct 9 ms 14680 KB Output is correct
47 Correct 8 ms 14684 KB Output is correct
48 Correct 9 ms 14684 KB Output is correct
49 Correct 8 ms 14740 KB Output is correct
50 Correct 8 ms 14680 KB Output is correct
51 Correct 9 ms 14684 KB Output is correct
52 Correct 9 ms 14808 KB Output is correct
53 Correct 10 ms 14808 KB Output is correct
54 Correct 9 ms 14804 KB Output is correct
55 Correct 9 ms 14808 KB Output is correct
56 Correct 9 ms 14808 KB Output is correct
57 Correct 10 ms 14812 KB Output is correct
58 Correct 9 ms 14804 KB Output is correct
59 Correct 8 ms 14812 KB Output is correct
60 Correct 9 ms 14804 KB Output is correct
61 Correct 9 ms 14788 KB Output is correct
62 Correct 8 ms 14804 KB Output is correct
63 Correct 10 ms 14804 KB Output is correct
64 Correct 9 ms 14820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14804 KB Output is correct
2 Correct 8 ms 14684 KB Output is correct
3 Correct 8 ms 14636 KB Output is correct
4 Correct 8 ms 14592 KB Output is correct
5 Correct 8 ms 14684 KB Output is correct
6 Correct 8 ms 14604 KB Output is correct
7 Correct 8 ms 14688 KB Output is correct
8 Correct 8 ms 14600 KB Output is correct
9 Correct 8 ms 14684 KB Output is correct
10 Correct 8 ms 14684 KB Output is correct
11 Correct 7 ms 14612 KB Output is correct
12 Correct 7 ms 14676 KB Output is correct
13 Correct 8 ms 14680 KB Output is correct
14 Correct 8 ms 14684 KB Output is correct
15 Correct 7 ms 14676 KB Output is correct
16 Correct 7 ms 14676 KB Output is correct
17 Correct 8 ms 14688 KB Output is correct
18 Correct 8 ms 14640 KB Output is correct
19 Correct 8 ms 14680 KB Output is correct
20 Correct 9 ms 14676 KB Output is correct
21 Correct 8 ms 14676 KB Output is correct
22 Correct 9 ms 14676 KB Output is correct
23 Correct 7 ms 14684 KB Output is correct
24 Correct 8 ms 14676 KB Output is correct
25 Correct 9 ms 14676 KB Output is correct
26 Correct 8 ms 14680 KB Output is correct
27 Correct 7 ms 14680 KB Output is correct
28 Correct 8 ms 14680 KB Output is correct
29 Correct 8 ms 14688 KB Output is correct
30 Correct 10 ms 14676 KB Output is correct
31 Correct 9 ms 14616 KB Output is correct
32 Correct 8 ms 14624 KB Output is correct
33 Correct 9 ms 14688 KB Output is correct
34 Correct 13 ms 14676 KB Output is correct
35 Correct 8 ms 14684 KB Output is correct
36 Correct 10 ms 14668 KB Output is correct
37 Correct 8 ms 14676 KB Output is correct
38 Correct 8 ms 14688 KB Output is correct
39 Correct 9 ms 14684 KB Output is correct
40 Correct 9 ms 14676 KB Output is correct
41 Correct 11 ms 14776 KB Output is correct
42 Correct 11 ms 14676 KB Output is correct
43 Correct 13 ms 14676 KB Output is correct
44 Correct 13 ms 14684 KB Output is correct
45 Correct 8 ms 14676 KB Output is correct
46 Correct 9 ms 14680 KB Output is correct
47 Correct 8 ms 14684 KB Output is correct
48 Correct 9 ms 14684 KB Output is correct
49 Correct 8 ms 14740 KB Output is correct
50 Correct 8 ms 14680 KB Output is correct
51 Correct 9 ms 14684 KB Output is correct
52 Correct 9 ms 14808 KB Output is correct
53 Correct 10 ms 14808 KB Output is correct
54 Correct 9 ms 14804 KB Output is correct
55 Correct 9 ms 14808 KB Output is correct
56 Correct 9 ms 14808 KB Output is correct
57 Correct 10 ms 14812 KB Output is correct
58 Correct 9 ms 14804 KB Output is correct
59 Correct 8 ms 14812 KB Output is correct
60 Correct 9 ms 14804 KB Output is correct
61 Correct 9 ms 14788 KB Output is correct
62 Correct 8 ms 14804 KB Output is correct
63 Correct 10 ms 14804 KB Output is correct
64 Correct 9 ms 14820 KB Output is correct
65 Correct 29 ms 19608 KB Output is correct
66 Correct 37 ms 20748 KB Output is correct
67 Correct 33 ms 20204 KB Output is correct
68 Correct 33 ms 20064 KB Output is correct
69 Correct 18 ms 17748 KB Output is correct
70 Correct 22 ms 18052 KB Output is correct
71 Correct 21 ms 17944 KB Output is correct
72 Correct 20 ms 17980 KB Output is correct
73 Correct 21 ms 18008 KB Output is correct
74 Correct 24 ms 17996 KB Output is correct
75 Correct 21 ms 18064 KB Output is correct
76 Correct 21 ms 18032 KB Output is correct
77 Correct 58 ms 26120 KB Output is correct
78 Correct 61 ms 27060 KB Output is correct
79 Correct 80 ms 29776 KB Output is correct
80 Correct 66 ms 27196 KB Output is correct
81 Correct 80 ms 28408 KB Output is correct
82 Correct 88 ms 26924 KB Output is correct
83 Correct 68 ms 26604 KB Output is correct
84 Correct 52 ms 24048 KB Output is correct
85 Correct 31 ms 20952 KB Output is correct
86 Correct 35 ms 21480 KB Output is correct
87 Correct 33 ms 21584 KB Output is correct
88 Correct 35 ms 21572 KB Output is correct
89 Correct 42 ms 21700 KB Output is correct
90 Correct 37 ms 21708 KB Output is correct
91 Correct 36 ms 21708 KB Output is correct
92 Correct 35 ms 21724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14804 KB Output is correct
2 Correct 8 ms 14684 KB Output is correct
3 Correct 8 ms 14636 KB Output is correct
4 Correct 8 ms 14592 KB Output is correct
5 Correct 8 ms 14684 KB Output is correct
6 Correct 8 ms 14604 KB Output is correct
7 Correct 8 ms 14688 KB Output is correct
8 Correct 8 ms 14600 KB Output is correct
9 Correct 8 ms 14684 KB Output is correct
10 Correct 8 ms 14684 KB Output is correct
11 Correct 7 ms 14612 KB Output is correct
12 Correct 7 ms 14676 KB Output is correct
13 Correct 8 ms 14680 KB Output is correct
14 Correct 8 ms 14684 KB Output is correct
15 Correct 7 ms 14676 KB Output is correct
16 Correct 7 ms 14676 KB Output is correct
17 Correct 8 ms 14688 KB Output is correct
18 Correct 8 ms 14640 KB Output is correct
19 Correct 8 ms 14680 KB Output is correct
20 Correct 9 ms 14676 KB Output is correct
21 Correct 8 ms 14676 KB Output is correct
22 Correct 9 ms 14676 KB Output is correct
23 Correct 7 ms 14684 KB Output is correct
24 Correct 8 ms 14676 KB Output is correct
25 Correct 9 ms 14676 KB Output is correct
26 Correct 8 ms 14680 KB Output is correct
27 Correct 7 ms 14680 KB Output is correct
28 Correct 8 ms 14680 KB Output is correct
29 Correct 8 ms 14688 KB Output is correct
30 Correct 10 ms 14676 KB Output is correct
31 Correct 9 ms 14616 KB Output is correct
32 Correct 8 ms 14624 KB Output is correct
33 Correct 9 ms 14688 KB Output is correct
34 Correct 13 ms 14676 KB Output is correct
35 Correct 8 ms 14684 KB Output is correct
36 Correct 10 ms 14668 KB Output is correct
37 Correct 8 ms 14676 KB Output is correct
38 Correct 8 ms 14688 KB Output is correct
39 Correct 9 ms 14684 KB Output is correct
40 Correct 9 ms 14676 KB Output is correct
41 Correct 11 ms 14776 KB Output is correct
42 Correct 11 ms 14676 KB Output is correct
43 Correct 13 ms 14676 KB Output is correct
44 Correct 13 ms 14684 KB Output is correct
45 Correct 8 ms 14676 KB Output is correct
46 Correct 9 ms 14680 KB Output is correct
47 Correct 8 ms 14684 KB Output is correct
48 Correct 9 ms 14684 KB Output is correct
49 Correct 8 ms 14740 KB Output is correct
50 Correct 8 ms 14680 KB Output is correct
51 Correct 9 ms 14684 KB Output is correct
52 Correct 9 ms 14808 KB Output is correct
53 Correct 10 ms 14808 KB Output is correct
54 Correct 9 ms 14804 KB Output is correct
55 Correct 9 ms 14808 KB Output is correct
56 Correct 9 ms 14808 KB Output is correct
57 Correct 10 ms 14812 KB Output is correct
58 Correct 9 ms 14804 KB Output is correct
59 Correct 8 ms 14812 KB Output is correct
60 Correct 9 ms 14804 KB Output is correct
61 Correct 9 ms 14788 KB Output is correct
62 Correct 8 ms 14804 KB Output is correct
63 Correct 10 ms 14804 KB Output is correct
64 Correct 9 ms 14820 KB Output is correct
65 Correct 29 ms 19608 KB Output is correct
66 Correct 37 ms 20748 KB Output is correct
67 Correct 33 ms 20204 KB Output is correct
68 Correct 33 ms 20064 KB Output is correct
69 Correct 18 ms 17748 KB Output is correct
70 Correct 22 ms 18052 KB Output is correct
71 Correct 21 ms 17944 KB Output is correct
72 Correct 20 ms 17980 KB Output is correct
73 Correct 21 ms 18008 KB Output is correct
74 Correct 24 ms 17996 KB Output is correct
75 Correct 21 ms 18064 KB Output is correct
76 Correct 21 ms 18032 KB Output is correct
77 Correct 58 ms 26120 KB Output is correct
78 Correct 61 ms 27060 KB Output is correct
79 Correct 80 ms 29776 KB Output is correct
80 Correct 66 ms 27196 KB Output is correct
81 Correct 80 ms 28408 KB Output is correct
82 Correct 88 ms 26924 KB Output is correct
83 Correct 68 ms 26604 KB Output is correct
84 Correct 52 ms 24048 KB Output is correct
85 Correct 31 ms 20952 KB Output is correct
86 Correct 35 ms 21480 KB Output is correct
87 Correct 33 ms 21584 KB Output is correct
88 Correct 35 ms 21572 KB Output is correct
89 Correct 42 ms 21700 KB Output is correct
90 Correct 37 ms 21708 KB Output is correct
91 Correct 36 ms 21708 KB Output is correct
92 Correct 35 ms 21724 KB Output is correct
93 Correct 335 ms 74572 KB Output is correct
94 Correct 189 ms 56636 KB Output is correct
95 Correct 148 ms 52644 KB Output is correct
96 Correct 378 ms 76732 KB Output is correct
97 Correct 323 ms 76288 KB Output is correct
98 Correct 308 ms 74104 KB Output is correct
99 Correct 89 ms 33468 KB Output is correct
100 Correct 126 ms 41032 KB Output is correct
101 Correct 176 ms 47660 KB Output is correct
102 Correct 216 ms 49300 KB Output is correct
103 Correct 66 ms 33232 KB Output is correct
104 Correct 68 ms 33460 KB Output is correct
105 Correct 109 ms 41136 KB Output is correct
106 Correct 276 ms 68788 KB Output is correct
107 Correct 117 ms 51540 KB Output is correct
108 Correct 224 ms 71372 KB Output is correct
109 Correct 695 ms 131692 KB Output is correct
110 Correct 1313 ms 223032 KB Output is correct
111 Correct 197 ms 48916 KB Output is correct
112 Correct 161 ms 42312 KB Output is correct
113 Correct 155 ms 40780 KB Output is correct
114 Correct 58 ms 27484 KB Output is correct
115 Correct 66 ms 28876 KB Output is correct
116 Correct 69 ms 28900 KB Output is correct
117 Correct 62 ms 28880 KB Output is correct
118 Correct 86 ms 29252 KB Output is correct
119 Correct 77 ms 29208 KB Output is correct
120 Correct 73 ms 29296 KB Output is correct
121 Correct 68 ms 29268 KB Output is correct
122 Correct 348 ms 74296 KB Output is correct
123 Correct 475 ms 92756 KB Output is correct
124 Correct 500 ms 87808 KB Output is correct
125 Correct 434 ms 81472 KB Output is correct
126 Correct 391 ms 73416 KB Output is correct
127 Correct 266 ms 56912 KB Output is correct
128 Correct 191 ms 46860 KB Output is correct
129 Correct 145 ms 40096 KB Output is correct
130 Correct 84 ms 33048 KB Output is correct
131 Correct 131 ms 40792 KB Output is correct
132 Correct 140 ms 43916 KB Output is correct
133 Correct 142 ms 43808 KB Output is correct
134 Correct 136 ms 43912 KB Output is correct
135 Correct 165 ms 44804 KB Output is correct
136 Correct 149 ms 44748 KB Output is correct
137 Correct 167 ms 44776 KB Output is correct
138 Correct 147 ms 44748 KB Output is correct
139 Correct 150 ms 44652 KB Output is correct
140 Correct 155 ms 44556 KB Output is correct
141 Correct 177 ms 44648 KB Output is correct
142 Correct 1136 ms 187612 KB Output is correct
143 Correct 1108 ms 174844 KB Output is correct
144 Correct 797 ms 130604 KB Output is correct
145 Correct 624 ms 103188 KB Output is correct
146 Correct 379 ms 73992 KB Output is correct
147 Correct 197 ms 51520 KB Output is correct
148 Correct 1075 ms 178540 KB Output is correct
149 Correct 1078 ms 174556 KB Output is correct
150 Correct 1255 ms 196428 KB Output is correct
151 Correct 292 ms 75256 KB Output is correct
152 Correct 297 ms 77336 KB Output is correct
153 Correct 351 ms 76748 KB Output is correct
154 Correct 321 ms 76640 KB Output is correct
155 Correct 351 ms 76956 KB Output is correct
156 Correct 320 ms 76684 KB Output is correct
157 Correct 337 ms 76848 KB Output is correct
158 Correct 343 ms 76736 KB Output is correct
159 Correct 336 ms 76612 KB Output is correct
160 Correct 345 ms 76588 KB Output is correct
161 Correct 348 ms 76492 KB Output is correct
162 Correct 345 ms 75460 KB Output is correct
163 Correct 334 ms 75400 KB Output is correct
164 Correct 391 ms 75532 KB Output is correct
165 Correct 355 ms 75380 KB Output is correct
166 Correct 350 ms 75452 KB Output is correct
167 Correct 332 ms 75340 KB Output is correct