답안 #748192

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
748192 2023-05-25T14:23:27 Z PVSekhar Amusement Park (CEOI19_amusementpark) C++14
100 / 100
2380 ms 4436 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
// const ll MOD = 1e9+7;
const ll MOD = 998244353;
const ll N=18;
const ll inv=499122177;
int edges[N+1];
ll ans[(1<<N)+1];
int cnt[(1<<N)+1];//parity of number of bits
int ind[(1<<N)+1];//independence of nodes in set

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    for(int i=0;i<=N;i++)edges[i]=0;
    for(int i=0;i<=(1<<N);i++)ans[i]=0;
    for(int i=0;i<=(1<<N);i++)cnt[i]=0;
    for(int i=0;i<=(1<<N);i++)ind[i]=0;

    int n,m,a,b;
    cin>>n>>m;
    for (int i = 0; i < m; i++)
    {
        cin>>a>>b;
        a--;
        b--;
        edges[a]+=(1<<b);
        edges[b]+=(1<<a);
    }
    for (int i = 0; i < (1<<n); i++)
    {
        int check=1,num=0;
        for (int k = 0; k < n; k++)
        {
            if((i^(1<<k))<i){
                if((edges[k]&i))check=0;
            }
            if(!check)break;
        }
        ind[i]=check;
        for (int k = 0; k < n; k++)if((i^(1<<k))<i)cnt[i]++;
        cnt[i]%=2;
    }
    
    ans[0]=1;
    for (int i = 1; i < (1<<n); i++)
    {
        for (int j = i; j > 0; j=((j-1)&i))
        {
            if(!ind[j])continue;
            // cout<<i<<" "<<j<<" "<<cnt<<"\n";
            if(cnt[j]){
                ans[i]+=ans[i^j];
            }else{
                ans[i]-=ans[i^j];
                ans[i]+=MOD;
            }
            ans[i]%=MOD;
        }
    }
    cout<<(((ans[(1<<n)-1]*m)%MOD)*inv)%MOD<<"\n";
    return 0;   
}

Compilation message

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:34:21: warning: unused variable 'num' [-Wunused-variable]
   34 |         int check=1,num=0;
      |                     ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4308 KB Output is correct
2 Correct 2 ms 4308 KB Output is correct
3 Correct 2 ms 4308 KB Output is correct
4 Correct 2 ms 4308 KB Output is correct
5 Correct 2 ms 4308 KB Output is correct
6 Correct 2 ms 4308 KB Output is correct
7 Correct 2 ms 4308 KB Output is correct
8 Correct 2 ms 4308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4308 KB Output is correct
2 Correct 2 ms 4308 KB Output is correct
3 Correct 2 ms 4308 KB Output is correct
4 Correct 2 ms 4308 KB Output is correct
5 Correct 2 ms 4308 KB Output is correct
6 Correct 2 ms 4308 KB Output is correct
7 Correct 2 ms 4308 KB Output is correct
8 Correct 2 ms 4308 KB Output is correct
9 Correct 2 ms 4308 KB Output is correct
10 Correct 3 ms 4308 KB Output is correct
11 Correct 2 ms 4308 KB Output is correct
12 Correct 2 ms 4308 KB Output is correct
13 Correct 2 ms 4308 KB Output is correct
14 Correct 2 ms 4308 KB Output is correct
15 Correct 2 ms 4308 KB Output is correct
16 Correct 2 ms 4308 KB Output is correct
17 Correct 2 ms 4308 KB Output is correct
18 Correct 2 ms 4308 KB Output is correct
19 Correct 2 ms 4308 KB Output is correct
20 Correct 2 ms 4308 KB Output is correct
21 Correct 2 ms 4308 KB Output is correct
22 Correct 2 ms 4308 KB Output is correct
23 Correct 2 ms 4308 KB Output is correct
24 Correct 2 ms 4308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4308 KB Output is correct
2 Correct 2 ms 4308 KB Output is correct
3 Correct 2 ms 4308 KB Output is correct
4 Correct 2 ms 4308 KB Output is correct
5 Correct 2 ms 4308 KB Output is correct
6 Correct 2 ms 4308 KB Output is correct
7 Correct 2 ms 4308 KB Output is correct
8 Correct 2 ms 4308 KB Output is correct
9 Correct 2 ms 4308 KB Output is correct
10 Correct 3 ms 4308 KB Output is correct
11 Correct 2 ms 4308 KB Output is correct
12 Correct 2 ms 4308 KB Output is correct
13 Correct 2 ms 4308 KB Output is correct
14 Correct 2 ms 4308 KB Output is correct
15 Correct 2 ms 4308 KB Output is correct
16 Correct 2 ms 4308 KB Output is correct
17 Correct 2 ms 4308 KB Output is correct
18 Correct 2 ms 4308 KB Output is correct
19 Correct 2 ms 4308 KB Output is correct
20 Correct 2 ms 4308 KB Output is correct
21 Correct 2 ms 4308 KB Output is correct
22 Correct 2 ms 4308 KB Output is correct
23 Correct 2 ms 4308 KB Output is correct
24 Correct 2 ms 4308 KB Output is correct
25 Correct 3 ms 4308 KB Output is correct
26 Correct 2 ms 4308 KB Output is correct
27 Correct 2 ms 4308 KB Output is correct
28 Correct 2 ms 4308 KB Output is correct
29 Correct 3 ms 4308 KB Output is correct
30 Correct 3 ms 4308 KB Output is correct
31 Correct 2 ms 4308 KB Output is correct
32 Correct 2 ms 4308 KB Output is correct
33 Correct 2 ms 4308 KB Output is correct
34 Correct 2 ms 4308 KB Output is correct
35 Correct 2 ms 4308 KB Output is correct
36 Correct 2 ms 4308 KB Output is correct
37 Correct 2 ms 4308 KB Output is correct
38 Correct 2 ms 4308 KB Output is correct
39 Correct 2 ms 4308 KB Output is correct
40 Correct 2 ms 4308 KB Output is correct
41 Correct 3 ms 4308 KB Output is correct
42 Correct 2 ms 4308 KB Output is correct
43 Correct 2 ms 4308 KB Output is correct
44 Correct 2 ms 4308 KB Output is correct
45 Correct 2 ms 4308 KB Output is correct
46 Correct 2 ms 4308 KB Output is correct
47 Correct 2 ms 4308 KB Output is correct
48 Correct 2 ms 4308 KB Output is correct
49 Correct 2 ms 4308 KB Output is correct
50 Correct 2 ms 4308 KB Output is correct
51 Correct 2 ms 4308 KB Output is correct
52 Correct 2 ms 4308 KB Output is correct
53 Correct 2 ms 4308 KB Output is correct
54 Correct 3 ms 4308 KB Output is correct
55 Correct 2 ms 4308 KB Output is correct
56 Correct 2 ms 4308 KB Output is correct
57 Correct 2 ms 4308 KB Output is correct
58 Correct 2 ms 4308 KB Output is correct
59 Correct 2 ms 4308 KB Output is correct
60 Correct 3 ms 4308 KB Output is correct
61 Correct 3 ms 4308 KB Output is correct
62 Correct 2 ms 4308 KB Output is correct
63 Correct 2 ms 4308 KB Output is correct
64 Correct 2 ms 4308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4308 KB Output is correct
2 Correct 2 ms 4308 KB Output is correct
3 Correct 2 ms 4308 KB Output is correct
4 Correct 2 ms 4308 KB Output is correct
5 Correct 2 ms 4308 KB Output is correct
6 Correct 2 ms 4308 KB Output is correct
7 Correct 2 ms 4308 KB Output is correct
8 Correct 2 ms 4308 KB Output is correct
9 Correct 2 ms 4308 KB Output is correct
10 Correct 3 ms 4308 KB Output is correct
11 Correct 2 ms 4308 KB Output is correct
12 Correct 2 ms 4308 KB Output is correct
13 Correct 2 ms 4308 KB Output is correct
14 Correct 2 ms 4308 KB Output is correct
15 Correct 2 ms 4308 KB Output is correct
16 Correct 2 ms 4308 KB Output is correct
17 Correct 2 ms 4308 KB Output is correct
18 Correct 2 ms 4308 KB Output is correct
19 Correct 2 ms 4308 KB Output is correct
20 Correct 2 ms 4308 KB Output is correct
21 Correct 2 ms 4308 KB Output is correct
22 Correct 2 ms 4308 KB Output is correct
23 Correct 2 ms 4308 KB Output is correct
24 Correct 2 ms 4308 KB Output is correct
25 Correct 3 ms 4308 KB Output is correct
26 Correct 2 ms 4308 KB Output is correct
27 Correct 2 ms 4308 KB Output is correct
28 Correct 2 ms 4308 KB Output is correct
29 Correct 3 ms 4308 KB Output is correct
30 Correct 3 ms 4308 KB Output is correct
31 Correct 2 ms 4308 KB Output is correct
32 Correct 2 ms 4308 KB Output is correct
33 Correct 2 ms 4308 KB Output is correct
34 Correct 2 ms 4308 KB Output is correct
35 Correct 2 ms 4308 KB Output is correct
36 Correct 2 ms 4308 KB Output is correct
37 Correct 2 ms 4308 KB Output is correct
38 Correct 2 ms 4308 KB Output is correct
39 Correct 2 ms 4308 KB Output is correct
40 Correct 2 ms 4308 KB Output is correct
41 Correct 3 ms 4308 KB Output is correct
42 Correct 2 ms 4308 KB Output is correct
43 Correct 2 ms 4308 KB Output is correct
44 Correct 2 ms 4308 KB Output is correct
45 Correct 2 ms 4308 KB Output is correct
46 Correct 2 ms 4308 KB Output is correct
47 Correct 2 ms 4308 KB Output is correct
48 Correct 2 ms 4308 KB Output is correct
49 Correct 2 ms 4308 KB Output is correct
50 Correct 2 ms 4308 KB Output is correct
51 Correct 2 ms 4308 KB Output is correct
52 Correct 2 ms 4308 KB Output is correct
53 Correct 2 ms 4308 KB Output is correct
54 Correct 3 ms 4308 KB Output is correct
55 Correct 2 ms 4308 KB Output is correct
56 Correct 2 ms 4308 KB Output is correct
57 Correct 2 ms 4308 KB Output is correct
58 Correct 2 ms 4308 KB Output is correct
59 Correct 2 ms 4308 KB Output is correct
60 Correct 3 ms 4308 KB Output is correct
61 Correct 3 ms 4308 KB Output is correct
62 Correct 2 ms 4308 KB Output is correct
63 Correct 2 ms 4308 KB Output is correct
64 Correct 2 ms 4308 KB Output is correct
65 Correct 12 ms 4424 KB Output is correct
66 Correct 10 ms 4420 KB Output is correct
67 Correct 9 ms 4308 KB Output is correct
68 Correct 9 ms 4308 KB Output is correct
69 Correct 23 ms 4308 KB Output is correct
70 Correct 17 ms 4308 KB Output is correct
71 Correct 18 ms 4424 KB Output is correct
72 Correct 18 ms 4308 KB Output is correct
73 Correct 14 ms 4308 KB Output is correct
74 Correct 15 ms 4424 KB Output is correct
75 Correct 13 ms 4308 KB Output is correct
76 Correct 15 ms 4420 KB Output is correct
77 Correct 30 ms 4308 KB Output is correct
78 Correct 28 ms 4420 KB Output is correct
79 Correct 28 ms 4416 KB Output is correct
80 Correct 26 ms 4420 KB Output is correct
81 Correct 24 ms 4424 KB Output is correct
82 Correct 21 ms 4416 KB Output is correct
83 Correct 20 ms 4308 KB Output is correct
84 Correct 19 ms 4416 KB Output is correct
85 Correct 63 ms 4400 KB Output is correct
86 Correct 47 ms 4308 KB Output is correct
87 Correct 48 ms 4428 KB Output is correct
88 Correct 52 ms 4308 KB Output is correct
89 Correct 39 ms 4328 KB Output is correct
90 Correct 39 ms 4424 KB Output is correct
91 Correct 36 ms 4308 KB Output is correct
92 Correct 38 ms 4308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4308 KB Output is correct
2 Correct 2 ms 4308 KB Output is correct
3 Correct 2 ms 4308 KB Output is correct
4 Correct 2 ms 4308 KB Output is correct
5 Correct 2 ms 4308 KB Output is correct
6 Correct 2 ms 4308 KB Output is correct
7 Correct 2 ms 4308 KB Output is correct
8 Correct 2 ms 4308 KB Output is correct
9 Correct 2 ms 4308 KB Output is correct
10 Correct 3 ms 4308 KB Output is correct
11 Correct 2 ms 4308 KB Output is correct
12 Correct 2 ms 4308 KB Output is correct
13 Correct 2 ms 4308 KB Output is correct
14 Correct 2 ms 4308 KB Output is correct
15 Correct 2 ms 4308 KB Output is correct
16 Correct 2 ms 4308 KB Output is correct
17 Correct 2 ms 4308 KB Output is correct
18 Correct 2 ms 4308 KB Output is correct
19 Correct 2 ms 4308 KB Output is correct
20 Correct 2 ms 4308 KB Output is correct
21 Correct 2 ms 4308 KB Output is correct
22 Correct 2 ms 4308 KB Output is correct
23 Correct 2 ms 4308 KB Output is correct
24 Correct 2 ms 4308 KB Output is correct
25 Correct 3 ms 4308 KB Output is correct
26 Correct 2 ms 4308 KB Output is correct
27 Correct 2 ms 4308 KB Output is correct
28 Correct 2 ms 4308 KB Output is correct
29 Correct 3 ms 4308 KB Output is correct
30 Correct 3 ms 4308 KB Output is correct
31 Correct 2 ms 4308 KB Output is correct
32 Correct 2 ms 4308 KB Output is correct
33 Correct 2 ms 4308 KB Output is correct
34 Correct 2 ms 4308 KB Output is correct
35 Correct 2 ms 4308 KB Output is correct
36 Correct 2 ms 4308 KB Output is correct
37 Correct 2 ms 4308 KB Output is correct
38 Correct 2 ms 4308 KB Output is correct
39 Correct 2 ms 4308 KB Output is correct
40 Correct 2 ms 4308 KB Output is correct
41 Correct 3 ms 4308 KB Output is correct
42 Correct 2 ms 4308 KB Output is correct
43 Correct 2 ms 4308 KB Output is correct
44 Correct 2 ms 4308 KB Output is correct
45 Correct 2 ms 4308 KB Output is correct
46 Correct 2 ms 4308 KB Output is correct
47 Correct 2 ms 4308 KB Output is correct
48 Correct 2 ms 4308 KB Output is correct
49 Correct 2 ms 4308 KB Output is correct
50 Correct 2 ms 4308 KB Output is correct
51 Correct 2 ms 4308 KB Output is correct
52 Correct 2 ms 4308 KB Output is correct
53 Correct 2 ms 4308 KB Output is correct
54 Correct 3 ms 4308 KB Output is correct
55 Correct 2 ms 4308 KB Output is correct
56 Correct 2 ms 4308 KB Output is correct
57 Correct 2 ms 4308 KB Output is correct
58 Correct 2 ms 4308 KB Output is correct
59 Correct 2 ms 4308 KB Output is correct
60 Correct 3 ms 4308 KB Output is correct
61 Correct 3 ms 4308 KB Output is correct
62 Correct 2 ms 4308 KB Output is correct
63 Correct 2 ms 4308 KB Output is correct
64 Correct 2 ms 4308 KB Output is correct
65 Correct 12 ms 4424 KB Output is correct
66 Correct 10 ms 4420 KB Output is correct
67 Correct 9 ms 4308 KB Output is correct
68 Correct 9 ms 4308 KB Output is correct
69 Correct 23 ms 4308 KB Output is correct
70 Correct 17 ms 4308 KB Output is correct
71 Correct 18 ms 4424 KB Output is correct
72 Correct 18 ms 4308 KB Output is correct
73 Correct 14 ms 4308 KB Output is correct
74 Correct 15 ms 4424 KB Output is correct
75 Correct 13 ms 4308 KB Output is correct
76 Correct 15 ms 4420 KB Output is correct
77 Correct 30 ms 4308 KB Output is correct
78 Correct 28 ms 4420 KB Output is correct
79 Correct 28 ms 4416 KB Output is correct
80 Correct 26 ms 4420 KB Output is correct
81 Correct 24 ms 4424 KB Output is correct
82 Correct 21 ms 4416 KB Output is correct
83 Correct 20 ms 4308 KB Output is correct
84 Correct 19 ms 4416 KB Output is correct
85 Correct 63 ms 4400 KB Output is correct
86 Correct 47 ms 4308 KB Output is correct
87 Correct 48 ms 4428 KB Output is correct
88 Correct 52 ms 4308 KB Output is correct
89 Correct 39 ms 4328 KB Output is correct
90 Correct 39 ms 4424 KB Output is correct
91 Correct 36 ms 4308 KB Output is correct
92 Correct 38 ms 4308 KB Output is correct
93 Correct 1193 ms 4400 KB Output is correct
94 Correct 1181 ms 4408 KB Output is correct
95 Correct 1199 ms 4408 KB Output is correct
96 Correct 945 ms 4408 KB Output is correct
97 Correct 770 ms 4400 KB Output is correct
98 Correct 880 ms 4308 KB Output is correct
99 Correct 96 ms 4404 KB Output is correct
100 Correct 81 ms 4408 KB Output is correct
101 Correct 71 ms 4404 KB Output is correct
102 Correct 65 ms 4308 KB Output is correct
103 Correct 809 ms 4420 KB Output is correct
104 Correct 438 ms 4308 KB Output is correct
105 Correct 321 ms 4404 KB Output is correct
106 Correct 216 ms 4308 KB Output is correct
107 Correct 2380 ms 4404 KB Output is correct
108 Correct 861 ms 4428 KB Output is correct
109 Correct 617 ms 4412 KB Output is correct
110 Correct 535 ms 4408 KB Output is correct
111 Correct 62 ms 4408 KB Output is correct
112 Correct 58 ms 4308 KB Output is correct
113 Correct 52 ms 4308 KB Output is correct
114 Correct 180 ms 4404 KB Output is correct
115 Correct 137 ms 4412 KB Output is correct
116 Correct 135 ms 4412 KB Output is correct
117 Correct 142 ms 4420 KB Output is correct
118 Correct 100 ms 4408 KB Output is correct
119 Correct 101 ms 4404 KB Output is correct
120 Correct 106 ms 4408 KB Output is correct
121 Correct 108 ms 4408 KB Output is correct
122 Correct 197 ms 4308 KB Output is correct
123 Correct 170 ms 4308 KB Output is correct
124 Correct 159 ms 4408 KB Output is correct
125 Correct 150 ms 4428 KB Output is correct
126 Correct 156 ms 4404 KB Output is correct
127 Correct 132 ms 4412 KB Output is correct
128 Correct 125 ms 4412 KB Output is correct
129 Correct 130 ms 4404 KB Output is correct
130 Correct 112 ms 4308 KB Output is correct
131 Correct 566 ms 4436 KB Output is correct
132 Correct 391 ms 4428 KB Output is correct
133 Correct 399 ms 4404 KB Output is correct
134 Correct 418 ms 4404 KB Output is correct
135 Correct 311 ms 4408 KB Output is correct
136 Correct 298 ms 4308 KB Output is correct
137 Correct 307 ms 4420 KB Output is correct
138 Correct 310 ms 4400 KB Output is correct
139 Correct 247 ms 4404 KB Output is correct
140 Correct 248 ms 4404 KB Output is correct
141 Correct 249 ms 4404 KB Output is correct
142 Correct 453 ms 4408 KB Output is correct
143 Correct 416 ms 4408 KB Output is correct
144 Correct 382 ms 4404 KB Output is correct
145 Correct 358 ms 4364 KB Output is correct
146 Correct 355 ms 4308 KB Output is correct
147 Correct 320 ms 4408 KB Output is correct
148 Correct 440 ms 4420 KB Output is correct
149 Correct 434 ms 4412 KB Output is correct
150 Correct 452 ms 4412 KB Output is correct
151 Correct 592 ms 4432 KB Output is correct
152 Correct 566 ms 4416 KB Output is correct
153 Correct 932 ms 4408 KB Output is correct
154 Correct 889 ms 4408 KB Output is correct
155 Correct 868 ms 4408 KB Output is correct
156 Correct 914 ms 4408 KB Output is correct
157 Correct 900 ms 4424 KB Output is correct
158 Correct 886 ms 4428 KB Output is correct
159 Correct 754 ms 4428 KB Output is correct
160 Correct 706 ms 4428 KB Output is correct
161 Correct 708 ms 4400 KB Output is correct
162 Correct 663 ms 4428 KB Output is correct
163 Correct 596 ms 4416 KB Output is correct
164 Correct 565 ms 4420 KB Output is correct
165 Correct 569 ms 4428 KB Output is correct
166 Correct 577 ms 4428 KB Output is correct
167 Correct 602 ms 4308 KB Output is correct