답안 #729043

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
729043 2023-04-23T12:26:49 Z Rafi22 Amusement Park (CEOI19_amusementpark) C++14
100 / 100
1915 ms 246276 KB
#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define ll long long
ll mod=998244353;
int inf=1000000007;
ll infl=1000000000000000007;

const int N=18;

unordered_map<int,int>DP[(1<<N)];
vector<int>inside[(1<<N)];
int G[N];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m,a,b;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>a>>b;
        a--,b--;
        G[a]^=(1<<b);
        G[b]^=(1<<a);
    }
    for(int i=0;i<(1<<n);i++)
    {
        for(int j=0;j<n;j++) if(i&(1<<j)) inside[i].pb(j);
    }
    DP[0][(1<<n)-1]=1;
    for(int a=0;a<(1<<n);a++)
    {
        int d=(1<<n)-1-a;
        for(auto [b,x]:DP[a])
        {
            for(auto k:inside[b])
            {
                int A=a^(1<<k),B=(b&((1<<n)-(1<<(k+1))))|(G[k]&((1<<n)-1-a-(1<<k)));
                int y=DP[A][B];
                y+=x;
                if(y>=mod) y-=mod;
                DP[A][B]=y;
            }
        }
    }
    cout<<(ll)DP[(1<<n)-1][0]*(ll)m%mod*499122177%mod;
    return 0;
}

Compilation message

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:44:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   44 |         for(auto [b,x]:DP[a])
      |                  ^
amusementpark.cpp:43:13: warning: unused variable 'd' [-Wunused-variable]
   43 |         int d=(1<<n)-1-a;
      |             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 20820 KB Output is correct
2 Correct 11 ms 20776 KB Output is correct
3 Correct 14 ms 20820 KB Output is correct
4 Correct 11 ms 20820 KB Output is correct
5 Correct 11 ms 20820 KB Output is correct
6 Correct 11 ms 20748 KB Output is correct
7 Correct 12 ms 20820 KB Output is correct
8 Correct 12 ms 20820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 20820 KB Output is correct
2 Correct 11 ms 20776 KB Output is correct
3 Correct 14 ms 20820 KB Output is correct
4 Correct 11 ms 20820 KB Output is correct
5 Correct 11 ms 20820 KB Output is correct
6 Correct 11 ms 20748 KB Output is correct
7 Correct 12 ms 20820 KB Output is correct
8 Correct 12 ms 20820 KB Output is correct
9 Correct 11 ms 20848 KB Output is correct
10 Correct 11 ms 20820 KB Output is correct
11 Correct 12 ms 20840 KB Output is correct
12 Correct 11 ms 20820 KB Output is correct
13 Correct 11 ms 20840 KB Output is correct
14 Correct 11 ms 20780 KB Output is correct
15 Correct 11 ms 20808 KB Output is correct
16 Correct 11 ms 20832 KB Output is correct
17 Correct 15 ms 20836 KB Output is correct
18 Correct 11 ms 20840 KB Output is correct
19 Correct 11 ms 20832 KB Output is correct
20 Correct 12 ms 20796 KB Output is correct
21 Correct 13 ms 20820 KB Output is correct
22 Correct 12 ms 20768 KB Output is correct
23 Correct 11 ms 20820 KB Output is correct
24 Correct 12 ms 20836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 20820 KB Output is correct
2 Correct 11 ms 20776 KB Output is correct
3 Correct 14 ms 20820 KB Output is correct
4 Correct 11 ms 20820 KB Output is correct
5 Correct 11 ms 20820 KB Output is correct
6 Correct 11 ms 20748 KB Output is correct
7 Correct 12 ms 20820 KB Output is correct
8 Correct 12 ms 20820 KB Output is correct
9 Correct 11 ms 20848 KB Output is correct
10 Correct 11 ms 20820 KB Output is correct
11 Correct 12 ms 20840 KB Output is correct
12 Correct 11 ms 20820 KB Output is correct
13 Correct 11 ms 20840 KB Output is correct
14 Correct 11 ms 20780 KB Output is correct
15 Correct 11 ms 20808 KB Output is correct
16 Correct 11 ms 20832 KB Output is correct
17 Correct 15 ms 20836 KB Output is correct
18 Correct 11 ms 20840 KB Output is correct
19 Correct 11 ms 20832 KB Output is correct
20 Correct 12 ms 20796 KB Output is correct
21 Correct 13 ms 20820 KB Output is correct
22 Correct 12 ms 20768 KB Output is correct
23 Correct 11 ms 20820 KB Output is correct
24 Correct 12 ms 20836 KB Output is correct
25 Correct 12 ms 20820 KB Output is correct
26 Correct 11 ms 20780 KB Output is correct
27 Correct 15 ms 20764 KB Output is correct
28 Correct 13 ms 20820 KB Output is correct
29 Correct 11 ms 20844 KB Output is correct
30 Correct 11 ms 20820 KB Output is correct
31 Correct 11 ms 20820 KB Output is correct
32 Correct 12 ms 20948 KB Output is correct
33 Correct 11 ms 20836 KB Output is correct
34 Correct 12 ms 20820 KB Output is correct
35 Correct 12 ms 20820 KB Output is correct
36 Correct 13 ms 20800 KB Output is correct
37 Correct 12 ms 20820 KB Output is correct
38 Correct 13 ms 20836 KB Output is correct
39 Correct 13 ms 20840 KB Output is correct
40 Correct 13 ms 20872 KB Output is correct
41 Correct 13 ms 20848 KB Output is correct
42 Correct 13 ms 20948 KB Output is correct
43 Correct 12 ms 20948 KB Output is correct
44 Correct 13 ms 20840 KB Output is correct
45 Correct 14 ms 20840 KB Output is correct
46 Correct 12 ms 20848 KB Output is correct
47 Correct 12 ms 20840 KB Output is correct
48 Correct 12 ms 20948 KB Output is correct
49 Correct 11 ms 20948 KB Output is correct
50 Correct 13 ms 20948 KB Output is correct
51 Correct 12 ms 20948 KB Output is correct
52 Correct 12 ms 21028 KB Output is correct
53 Correct 12 ms 20948 KB Output is correct
54 Correct 13 ms 20964 KB Output is correct
55 Correct 13 ms 20948 KB Output is correct
56 Correct 15 ms 21100 KB Output is correct
57 Correct 13 ms 21076 KB Output is correct
58 Correct 12 ms 20968 KB Output is correct
59 Correct 13 ms 21100 KB Output is correct
60 Correct 13 ms 20948 KB Output is correct
61 Correct 12 ms 21036 KB Output is correct
62 Correct 12 ms 21060 KB Output is correct
63 Correct 12 ms 20972 KB Output is correct
64 Correct 14 ms 20960 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 20820 KB Output is correct
2 Correct 11 ms 20776 KB Output is correct
3 Correct 14 ms 20820 KB Output is correct
4 Correct 11 ms 20820 KB Output is correct
5 Correct 11 ms 20820 KB Output is correct
6 Correct 11 ms 20748 KB Output is correct
7 Correct 12 ms 20820 KB Output is correct
8 Correct 12 ms 20820 KB Output is correct
9 Correct 11 ms 20848 KB Output is correct
10 Correct 11 ms 20820 KB Output is correct
11 Correct 12 ms 20840 KB Output is correct
12 Correct 11 ms 20820 KB Output is correct
13 Correct 11 ms 20840 KB Output is correct
14 Correct 11 ms 20780 KB Output is correct
15 Correct 11 ms 20808 KB Output is correct
16 Correct 11 ms 20832 KB Output is correct
17 Correct 15 ms 20836 KB Output is correct
18 Correct 11 ms 20840 KB Output is correct
19 Correct 11 ms 20832 KB Output is correct
20 Correct 12 ms 20796 KB Output is correct
21 Correct 13 ms 20820 KB Output is correct
22 Correct 12 ms 20768 KB Output is correct
23 Correct 11 ms 20820 KB Output is correct
24 Correct 12 ms 20836 KB Output is correct
25 Correct 12 ms 20820 KB Output is correct
26 Correct 11 ms 20780 KB Output is correct
27 Correct 15 ms 20764 KB Output is correct
28 Correct 13 ms 20820 KB Output is correct
29 Correct 11 ms 20844 KB Output is correct
30 Correct 11 ms 20820 KB Output is correct
31 Correct 11 ms 20820 KB Output is correct
32 Correct 12 ms 20948 KB Output is correct
33 Correct 11 ms 20836 KB Output is correct
34 Correct 12 ms 20820 KB Output is correct
35 Correct 12 ms 20820 KB Output is correct
36 Correct 13 ms 20800 KB Output is correct
37 Correct 12 ms 20820 KB Output is correct
38 Correct 13 ms 20836 KB Output is correct
39 Correct 13 ms 20840 KB Output is correct
40 Correct 13 ms 20872 KB Output is correct
41 Correct 13 ms 20848 KB Output is correct
42 Correct 13 ms 20948 KB Output is correct
43 Correct 12 ms 20948 KB Output is correct
44 Correct 13 ms 20840 KB Output is correct
45 Correct 14 ms 20840 KB Output is correct
46 Correct 12 ms 20848 KB Output is correct
47 Correct 12 ms 20840 KB Output is correct
48 Correct 12 ms 20948 KB Output is correct
49 Correct 11 ms 20948 KB Output is correct
50 Correct 13 ms 20948 KB Output is correct
51 Correct 12 ms 20948 KB Output is correct
52 Correct 12 ms 21028 KB Output is correct
53 Correct 12 ms 20948 KB Output is correct
54 Correct 13 ms 20964 KB Output is correct
55 Correct 13 ms 20948 KB Output is correct
56 Correct 15 ms 21100 KB Output is correct
57 Correct 13 ms 21076 KB Output is correct
58 Correct 12 ms 20968 KB Output is correct
59 Correct 13 ms 21100 KB Output is correct
60 Correct 13 ms 20948 KB Output is correct
61 Correct 12 ms 21036 KB Output is correct
62 Correct 12 ms 21060 KB Output is correct
63 Correct 12 ms 20972 KB Output is correct
64 Correct 14 ms 20960 KB Output is correct
65 Correct 41 ms 26604 KB Output is correct
66 Correct 57 ms 27700 KB Output is correct
67 Correct 52 ms 27280 KB Output is correct
68 Correct 53 ms 26972 KB Output is correct
69 Correct 30 ms 24676 KB Output is correct
70 Correct 33 ms 24948 KB Output is correct
71 Correct 36 ms 25028 KB Output is correct
72 Correct 32 ms 25008 KB Output is correct
73 Correct 37 ms 25108 KB Output is correct
74 Correct 43 ms 25008 KB Output is correct
75 Correct 33 ms 25048 KB Output is correct
76 Correct 34 ms 25080 KB Output is correct
77 Correct 86 ms 34148 KB Output is correct
78 Correct 90 ms 35084 KB Output is correct
79 Correct 118 ms 37648 KB Output is correct
80 Correct 103 ms 35188 KB Output is correct
81 Correct 117 ms 36376 KB Output is correct
82 Correct 108 ms 34840 KB Output is correct
83 Correct 117 ms 34488 KB Output is correct
84 Correct 89 ms 32024 KB Output is correct
85 Correct 46 ms 28920 KB Output is correct
86 Correct 50 ms 29472 KB Output is correct
87 Correct 54 ms 29508 KB Output is correct
88 Correct 52 ms 29516 KB Output is correct
89 Correct 57 ms 29644 KB Output is correct
90 Correct 56 ms 29644 KB Output is correct
91 Correct 58 ms 29716 KB Output is correct
92 Correct 54 ms 29604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 20820 KB Output is correct
2 Correct 11 ms 20776 KB Output is correct
3 Correct 14 ms 20820 KB Output is correct
4 Correct 11 ms 20820 KB Output is correct
5 Correct 11 ms 20820 KB Output is correct
6 Correct 11 ms 20748 KB Output is correct
7 Correct 12 ms 20820 KB Output is correct
8 Correct 12 ms 20820 KB Output is correct
9 Correct 11 ms 20848 KB Output is correct
10 Correct 11 ms 20820 KB Output is correct
11 Correct 12 ms 20840 KB Output is correct
12 Correct 11 ms 20820 KB Output is correct
13 Correct 11 ms 20840 KB Output is correct
14 Correct 11 ms 20780 KB Output is correct
15 Correct 11 ms 20808 KB Output is correct
16 Correct 11 ms 20832 KB Output is correct
17 Correct 15 ms 20836 KB Output is correct
18 Correct 11 ms 20840 KB Output is correct
19 Correct 11 ms 20832 KB Output is correct
20 Correct 12 ms 20796 KB Output is correct
21 Correct 13 ms 20820 KB Output is correct
22 Correct 12 ms 20768 KB Output is correct
23 Correct 11 ms 20820 KB Output is correct
24 Correct 12 ms 20836 KB Output is correct
25 Correct 12 ms 20820 KB Output is correct
26 Correct 11 ms 20780 KB Output is correct
27 Correct 15 ms 20764 KB Output is correct
28 Correct 13 ms 20820 KB Output is correct
29 Correct 11 ms 20844 KB Output is correct
30 Correct 11 ms 20820 KB Output is correct
31 Correct 11 ms 20820 KB Output is correct
32 Correct 12 ms 20948 KB Output is correct
33 Correct 11 ms 20836 KB Output is correct
34 Correct 12 ms 20820 KB Output is correct
35 Correct 12 ms 20820 KB Output is correct
36 Correct 13 ms 20800 KB Output is correct
37 Correct 12 ms 20820 KB Output is correct
38 Correct 13 ms 20836 KB Output is correct
39 Correct 13 ms 20840 KB Output is correct
40 Correct 13 ms 20872 KB Output is correct
41 Correct 13 ms 20848 KB Output is correct
42 Correct 13 ms 20948 KB Output is correct
43 Correct 12 ms 20948 KB Output is correct
44 Correct 13 ms 20840 KB Output is correct
45 Correct 14 ms 20840 KB Output is correct
46 Correct 12 ms 20848 KB Output is correct
47 Correct 12 ms 20840 KB Output is correct
48 Correct 12 ms 20948 KB Output is correct
49 Correct 11 ms 20948 KB Output is correct
50 Correct 13 ms 20948 KB Output is correct
51 Correct 12 ms 20948 KB Output is correct
52 Correct 12 ms 21028 KB Output is correct
53 Correct 12 ms 20948 KB Output is correct
54 Correct 13 ms 20964 KB Output is correct
55 Correct 13 ms 20948 KB Output is correct
56 Correct 15 ms 21100 KB Output is correct
57 Correct 13 ms 21076 KB Output is correct
58 Correct 12 ms 20968 KB Output is correct
59 Correct 13 ms 21100 KB Output is correct
60 Correct 13 ms 20948 KB Output is correct
61 Correct 12 ms 21036 KB Output is correct
62 Correct 12 ms 21060 KB Output is correct
63 Correct 12 ms 20972 KB Output is correct
64 Correct 14 ms 20960 KB Output is correct
65 Correct 41 ms 26604 KB Output is correct
66 Correct 57 ms 27700 KB Output is correct
67 Correct 52 ms 27280 KB Output is correct
68 Correct 53 ms 26972 KB Output is correct
69 Correct 30 ms 24676 KB Output is correct
70 Correct 33 ms 24948 KB Output is correct
71 Correct 36 ms 25028 KB Output is correct
72 Correct 32 ms 25008 KB Output is correct
73 Correct 37 ms 25108 KB Output is correct
74 Correct 43 ms 25008 KB Output is correct
75 Correct 33 ms 25048 KB Output is correct
76 Correct 34 ms 25080 KB Output is correct
77 Correct 86 ms 34148 KB Output is correct
78 Correct 90 ms 35084 KB Output is correct
79 Correct 118 ms 37648 KB Output is correct
80 Correct 103 ms 35188 KB Output is correct
81 Correct 117 ms 36376 KB Output is correct
82 Correct 108 ms 34840 KB Output is correct
83 Correct 117 ms 34488 KB Output is correct
84 Correct 89 ms 32024 KB Output is correct
85 Correct 46 ms 28920 KB Output is correct
86 Correct 50 ms 29472 KB Output is correct
87 Correct 54 ms 29508 KB Output is correct
88 Correct 52 ms 29516 KB Output is correct
89 Correct 57 ms 29644 KB Output is correct
90 Correct 56 ms 29644 KB Output is correct
91 Correct 58 ms 29716 KB Output is correct
92 Correct 54 ms 29604 KB Output is correct
93 Correct 485 ms 97948 KB Output is correct
94 Correct 260 ms 79748 KB Output is correct
95 Correct 187 ms 75892 KB Output is correct
96 Correct 503 ms 100112 KB Output is correct
97 Correct 487 ms 99476 KB Output is correct
98 Correct 471 ms 97276 KB Output is correct
99 Correct 137 ms 43468 KB Output is correct
100 Correct 210 ms 51128 KB Output is correct
101 Correct 249 ms 57772 KB Output is correct
102 Correct 268 ms 59324 KB Output is correct
103 Correct 82 ms 47352 KB Output is correct
104 Correct 90 ms 47712 KB Output is correct
105 Correct 146 ms 55376 KB Output is correct
106 Correct 383 ms 83096 KB Output is correct
107 Correct 153 ms 74780 KB Output is correct
108 Correct 287 ms 94700 KB Output is correct
109 Correct 873 ms 154936 KB Output is correct
110 Correct 1915 ms 246276 KB Output is correct
111 Correct 292 ms 59008 KB Output is correct
112 Correct 253 ms 52228 KB Output is correct
113 Correct 279 ms 50764 KB Output is correct
114 Correct 89 ms 37512 KB Output is correct
115 Correct 99 ms 38844 KB Output is correct
116 Correct 95 ms 38800 KB Output is correct
117 Correct 106 ms 38864 KB Output is correct
118 Correct 106 ms 39216 KB Output is correct
119 Correct 110 ms 39204 KB Output is correct
120 Correct 116 ms 39248 KB Output is correct
121 Correct 104 ms 39308 KB Output is correct
122 Correct 491 ms 88628 KB Output is correct
123 Correct 697 ms 107180 KB Output is correct
124 Correct 688 ms 102328 KB Output is correct
125 Correct 667 ms 95828 KB Output is correct
126 Correct 585 ms 87720 KB Output is correct
127 Correct 391 ms 71264 KB Output is correct
128 Correct 300 ms 61340 KB Output is correct
129 Correct 202 ms 54444 KB Output is correct
130 Correct 125 ms 47344 KB Output is correct
131 Correct 188 ms 55132 KB Output is correct
132 Correct 202 ms 58192 KB Output is correct
133 Correct 210 ms 58128 KB Output is correct
134 Correct 202 ms 58112 KB Output is correct
135 Correct 228 ms 59108 KB Output is correct
136 Correct 243 ms 59092 KB Output is correct
137 Correct 217 ms 59128 KB Output is correct
138 Correct 212 ms 59016 KB Output is correct
139 Correct 257 ms 58956 KB Output is correct
140 Correct 221 ms 58940 KB Output is correct
141 Correct 244 ms 59076 KB Output is correct
142 Correct 1594 ms 211036 KB Output is correct
143 Correct 1600 ms 198264 KB Output is correct
144 Correct 1190 ms 153916 KB Output is correct
145 Correct 997 ms 126380 KB Output is correct
146 Correct 587 ms 97164 KB Output is correct
147 Correct 246 ms 74872 KB Output is correct
148 Correct 1598 ms 201892 KB Output is correct
149 Correct 1547 ms 198004 KB Output is correct
150 Correct 1738 ms 219712 KB Output is correct
151 Correct 416 ms 98504 KB Output is correct
152 Correct 450 ms 100584 KB Output is correct
153 Correct 488 ms 99924 KB Output is correct
154 Correct 512 ms 99988 KB Output is correct
155 Correct 494 ms 100032 KB Output is correct
156 Correct 474 ms 100048 KB Output is correct
157 Correct 503 ms 99988 KB Output is correct
158 Correct 527 ms 100004 KB Output is correct
159 Correct 539 ms 99880 KB Output is correct
160 Correct 508 ms 99908 KB Output is correct
161 Correct 474 ms 99880 KB Output is correct
162 Correct 519 ms 98644 KB Output is correct
163 Correct 521 ms 98720 KB Output is correct
164 Correct 553 ms 98780 KB Output is correct
165 Correct 513 ms 98724 KB Output is correct
166 Correct 500 ms 98724 KB Output is correct
167 Correct 484 ms 98608 KB Output is correct