답안 #498040

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
498040 2021-12-24T09:58:53 Z andrei_boaca Amusement Park (CEOI19_amusementpark) C++14
100 / 100
1057 ms 2832 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const ll mod=998244353,inv2=499122177;
int n,m,bits[25],lg,cmask[25];
int dp[(1<<18)+5];
int B[25];
bool isthere[1000006];
ll gethash(ll x, ll y)
{
    ll rez=(x<<18);
    rez+=y;
    return rez;
}
bool good[(1<<18)+5],edge[25][25];
int bit[(1<<18)+5];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int a,b;
        cin>>a>>b;
        cmask[a]+=(1<<(b-1));
        cmask[b]+=(1<<(a-1));
        a--;
        b--;
        edge[a][b]=edge[b][a]=1;
    }
    for(int mask=0;mask<(1<<n);mask++)
    {
        for(int a=0;a<n;a++)
            if((mask>>a)&1)
                for(int b=0;b<n;b++)
                    if((mask>>b)&1)
                        good[mask]|=edge[a][b];
        good[mask]= !good[mask];
        if(mask==0)
            bit[mask]=-1;
        else
        {
            int lsb=(mask&(-mask));
            bit[mask]=bit[mask^lsb]*(-1);
        }
    }
    for(int mask=0;mask<(1<<n);mask++)
    {
        if(good[mask])
        {
            dp[mask]=1;
            continue;
        }
        for(int submask=mask;submask>0;submask=(submask-1)&mask)
            if(good[submask]&&submask!=mask)
                dp[mask]=(dp[mask]+bit[submask]*dp[mask^submask]+mod)%mod;
    }
    ll ans=dp[(1<<n)-1];
    ans=(ans*m)%mod;
    ans=(ans*inv2)%mod;
    cout<<ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 288 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 288 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 308 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 1 ms 208 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 0 ms 308 KB Output is correct
23 Correct 0 ms 308 KB Output is correct
24 Correct 1 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 288 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 308 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 1 ms 208 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 0 ms 308 KB Output is correct
23 Correct 0 ms 308 KB Output is correct
24 Correct 1 ms 308 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 0 ms 304 KB Output is correct
27 Correct 1 ms 208 KB Output is correct
28 Correct 0 ms 208 KB Output is correct
29 Correct 1 ms 208 KB Output is correct
30 Correct 0 ms 208 KB Output is correct
31 Correct 1 ms 304 KB Output is correct
32 Correct 1 ms 304 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 208 KB Output is correct
36 Correct 1 ms 208 KB Output is correct
37 Correct 0 ms 208 KB Output is correct
38 Correct 1 ms 308 KB Output is correct
39 Correct 1 ms 208 KB Output is correct
40 Correct 0 ms 208 KB Output is correct
41 Correct 1 ms 208 KB Output is correct
42 Correct 1 ms 208 KB Output is correct
43 Correct 1 ms 208 KB Output is correct
44 Correct 1 ms 208 KB Output is correct
45 Correct 1 ms 208 KB Output is correct
46 Correct 1 ms 208 KB Output is correct
47 Correct 1 ms 208 KB Output is correct
48 Correct 1 ms 208 KB Output is correct
49 Correct 0 ms 208 KB Output is correct
50 Correct 0 ms 208 KB Output is correct
51 Correct 1 ms 208 KB Output is correct
52 Correct 1 ms 316 KB Output is correct
53 Correct 1 ms 308 KB Output is correct
54 Correct 1 ms 336 KB Output is correct
55 Correct 1 ms 208 KB Output is correct
56 Correct 1 ms 208 KB Output is correct
57 Correct 1 ms 312 KB Output is correct
58 Correct 1 ms 208 KB Output is correct
59 Correct 1 ms 356 KB Output is correct
60 Correct 1 ms 336 KB Output is correct
61 Correct 1 ms 208 KB Output is correct
62 Correct 1 ms 308 KB Output is correct
63 Correct 1 ms 208 KB Output is correct
64 Correct 1 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 288 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 308 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 1 ms 208 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 0 ms 308 KB Output is correct
23 Correct 0 ms 308 KB Output is correct
24 Correct 1 ms 308 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 0 ms 304 KB Output is correct
27 Correct 1 ms 208 KB Output is correct
28 Correct 0 ms 208 KB Output is correct
29 Correct 1 ms 208 KB Output is correct
30 Correct 0 ms 208 KB Output is correct
31 Correct 1 ms 304 KB Output is correct
32 Correct 1 ms 304 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 208 KB Output is correct
36 Correct 1 ms 208 KB Output is correct
37 Correct 0 ms 208 KB Output is correct
38 Correct 1 ms 308 KB Output is correct
39 Correct 1 ms 208 KB Output is correct
40 Correct 0 ms 208 KB Output is correct
41 Correct 1 ms 208 KB Output is correct
42 Correct 1 ms 208 KB Output is correct
43 Correct 1 ms 208 KB Output is correct
44 Correct 1 ms 208 KB Output is correct
45 Correct 1 ms 208 KB Output is correct
46 Correct 1 ms 208 KB Output is correct
47 Correct 1 ms 208 KB Output is correct
48 Correct 1 ms 208 KB Output is correct
49 Correct 0 ms 208 KB Output is correct
50 Correct 0 ms 208 KB Output is correct
51 Correct 1 ms 208 KB Output is correct
52 Correct 1 ms 316 KB Output is correct
53 Correct 1 ms 308 KB Output is correct
54 Correct 1 ms 336 KB Output is correct
55 Correct 1 ms 208 KB Output is correct
56 Correct 1 ms 208 KB Output is correct
57 Correct 1 ms 312 KB Output is correct
58 Correct 1 ms 208 KB Output is correct
59 Correct 1 ms 356 KB Output is correct
60 Correct 1 ms 336 KB Output is correct
61 Correct 1 ms 208 KB Output is correct
62 Correct 1 ms 308 KB Output is correct
63 Correct 1 ms 208 KB Output is correct
64 Correct 1 ms 312 KB Output is correct
65 Correct 14 ms 408 KB Output is correct
66 Correct 14 ms 428 KB Output is correct
67 Correct 14 ms 444 KB Output is correct
68 Correct 13 ms 464 KB Output is correct
69 Correct 16 ms 464 KB Output is correct
70 Correct 16 ms 464 KB Output is correct
71 Correct 21 ms 396 KB Output is correct
72 Correct 19 ms 424 KB Output is correct
73 Correct 15 ms 464 KB Output is correct
74 Correct 16 ms 416 KB Output is correct
75 Correct 16 ms 448 KB Output is correct
76 Correct 18 ms 464 KB Output is correct
77 Correct 48 ms 560 KB Output is correct
78 Correct 36 ms 532 KB Output is correct
79 Correct 36 ms 512 KB Output is correct
80 Correct 39 ms 568 KB Output is correct
81 Correct 37 ms 492 KB Output is correct
82 Correct 31 ms 576 KB Output is correct
83 Correct 33 ms 568 KB Output is correct
84 Correct 32 ms 584 KB Output is correct
85 Correct 47 ms 488 KB Output is correct
86 Correct 46 ms 584 KB Output is correct
87 Correct 48 ms 588 KB Output is correct
88 Correct 51 ms 556 KB Output is correct
89 Correct 40 ms 568 KB Output is correct
90 Correct 43 ms 588 KB Output is correct
91 Correct 52 ms 516 KB Output is correct
92 Correct 47 ms 556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 288 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 308 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 1 ms 208 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 0 ms 308 KB Output is correct
23 Correct 0 ms 308 KB Output is correct
24 Correct 1 ms 308 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 0 ms 304 KB Output is correct
27 Correct 1 ms 208 KB Output is correct
28 Correct 0 ms 208 KB Output is correct
29 Correct 1 ms 208 KB Output is correct
30 Correct 0 ms 208 KB Output is correct
31 Correct 1 ms 304 KB Output is correct
32 Correct 1 ms 304 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 208 KB Output is correct
36 Correct 1 ms 208 KB Output is correct
37 Correct 0 ms 208 KB Output is correct
38 Correct 1 ms 308 KB Output is correct
39 Correct 1 ms 208 KB Output is correct
40 Correct 0 ms 208 KB Output is correct
41 Correct 1 ms 208 KB Output is correct
42 Correct 1 ms 208 KB Output is correct
43 Correct 1 ms 208 KB Output is correct
44 Correct 1 ms 208 KB Output is correct
45 Correct 1 ms 208 KB Output is correct
46 Correct 1 ms 208 KB Output is correct
47 Correct 1 ms 208 KB Output is correct
48 Correct 1 ms 208 KB Output is correct
49 Correct 0 ms 208 KB Output is correct
50 Correct 0 ms 208 KB Output is correct
51 Correct 1 ms 208 KB Output is correct
52 Correct 1 ms 316 KB Output is correct
53 Correct 1 ms 308 KB Output is correct
54 Correct 1 ms 336 KB Output is correct
55 Correct 1 ms 208 KB Output is correct
56 Correct 1 ms 208 KB Output is correct
57 Correct 1 ms 312 KB Output is correct
58 Correct 1 ms 208 KB Output is correct
59 Correct 1 ms 356 KB Output is correct
60 Correct 1 ms 336 KB Output is correct
61 Correct 1 ms 208 KB Output is correct
62 Correct 1 ms 308 KB Output is correct
63 Correct 1 ms 208 KB Output is correct
64 Correct 1 ms 312 KB Output is correct
65 Correct 14 ms 408 KB Output is correct
66 Correct 14 ms 428 KB Output is correct
67 Correct 14 ms 444 KB Output is correct
68 Correct 13 ms 464 KB Output is correct
69 Correct 16 ms 464 KB Output is correct
70 Correct 16 ms 464 KB Output is correct
71 Correct 21 ms 396 KB Output is correct
72 Correct 19 ms 424 KB Output is correct
73 Correct 15 ms 464 KB Output is correct
74 Correct 16 ms 416 KB Output is correct
75 Correct 16 ms 448 KB Output is correct
76 Correct 18 ms 464 KB Output is correct
77 Correct 48 ms 560 KB Output is correct
78 Correct 36 ms 532 KB Output is correct
79 Correct 36 ms 512 KB Output is correct
80 Correct 39 ms 568 KB Output is correct
81 Correct 37 ms 492 KB Output is correct
82 Correct 31 ms 576 KB Output is correct
83 Correct 33 ms 568 KB Output is correct
84 Correct 32 ms 584 KB Output is correct
85 Correct 47 ms 488 KB Output is correct
86 Correct 46 ms 584 KB Output is correct
87 Correct 48 ms 588 KB Output is correct
88 Correct 51 ms 556 KB Output is correct
89 Correct 40 ms 568 KB Output is correct
90 Correct 43 ms 588 KB Output is correct
91 Correct 52 ms 516 KB Output is correct
92 Correct 47 ms 556 KB Output is correct
93 Correct 1027 ms 2660 KB Output is correct
94 Correct 1057 ms 2568 KB Output is correct
95 Correct 1014 ms 2580 KB Output is correct
96 Correct 827 ms 2768 KB Output is correct
97 Correct 862 ms 2680 KB Output is correct
98 Correct 981 ms 2764 KB Output is correct
99 Correct 140 ms 824 KB Output is correct
100 Correct 100 ms 824 KB Output is correct
101 Correct 90 ms 824 KB Output is correct
102 Correct 86 ms 848 KB Output is correct
103 Correct 56 ms 1428 KB Output is correct
104 Correct 465 ms 1496 KB Output is correct
105 Correct 389 ms 1348 KB Output is correct
106 Correct 261 ms 1384 KB Output is correct
107 Correct 110 ms 2576 KB Output is correct
108 Correct 1026 ms 2736 KB Output is correct
109 Correct 711 ms 2596 KB Output is correct
110 Correct 638 ms 2772 KB Output is correct
111 Correct 107 ms 824 KB Output is correct
112 Correct 81 ms 976 KB Output is correct
113 Correct 77 ms 832 KB Output is correct
114 Correct 120 ms 876 KB Output is correct
115 Correct 131 ms 876 KB Output is correct
116 Correct 141 ms 780 KB Output is correct
117 Correct 147 ms 852 KB Output is correct
118 Correct 113 ms 1000 KB Output is correct
119 Correct 121 ms 804 KB Output is correct
120 Correct 147 ms 836 KB Output is correct
121 Correct 129 ms 856 KB Output is correct
122 Correct 273 ms 1452 KB Output is correct
123 Correct 247 ms 1356 KB Output is correct
124 Correct 214 ms 1436 KB Output is correct
125 Correct 221 ms 1392 KB Output is correct
126 Correct 199 ms 1380 KB Output is correct
127 Correct 192 ms 1400 KB Output is correct
128 Correct 215 ms 1332 KB Output is correct
129 Correct 179 ms 1360 KB Output is correct
130 Correct 177 ms 1368 KB Output is correct
131 Correct 399 ms 1508 KB Output is correct
132 Correct 353 ms 1416 KB Output is correct
133 Correct 376 ms 1400 KB Output is correct
134 Correct 435 ms 1384 KB Output is correct
135 Correct 302 ms 1368 KB Output is correct
136 Correct 340 ms 1332 KB Output is correct
137 Correct 345 ms 1480 KB Output is correct
138 Correct 390 ms 1364 KB Output is correct
139 Correct 268 ms 1528 KB Output is correct
140 Correct 307 ms 1540 KB Output is correct
141 Correct 340 ms 1432 KB Output is correct
142 Correct 579 ms 2548 KB Output is correct
143 Correct 604 ms 2592 KB Output is correct
144 Correct 543 ms 2772 KB Output is correct
145 Correct 534 ms 2712 KB Output is correct
146 Correct 562 ms 2600 KB Output is correct
147 Correct 513 ms 2596 KB Output is correct
148 Correct 620 ms 2504 KB Output is correct
149 Correct 585 ms 2488 KB Output is correct
150 Correct 569 ms 2484 KB Output is correct
151 Correct 795 ms 2632 KB Output is correct
152 Correct 822 ms 2576 KB Output is correct
153 Correct 817 ms 2580 KB Output is correct
154 Correct 843 ms 2564 KB Output is correct
155 Correct 976 ms 2832 KB Output is correct
156 Correct 1045 ms 2652 KB Output is correct
157 Correct 902 ms 2608 KB Output is correct
158 Correct 1014 ms 2544 KB Output is correct
159 Correct 755 ms 2604 KB Output is correct
160 Correct 809 ms 2784 KB Output is correct
161 Correct 916 ms 2588 KB Output is correct
162 Correct 731 ms 2504 KB Output is correct
163 Correct 691 ms 2528 KB Output is correct
164 Correct 710 ms 2576 KB Output is correct
165 Correct 736 ms 2568 KB Output is correct
166 Correct 810 ms 2540 KB Output is correct
167 Correct 777 ms 2560 KB Output is correct