Submission #1110038

# Submission time Handle Problem Language Result Execution time Memory
1110038 2024-11-08T14:08:49 Z koukirocks Amusement Park (CEOI19_amusementpark) C++17
100 / 100
2325 ms 2384 KB
#include <bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0); cin.tie(0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("popcnt")
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MAX=2e5+10,P=998244353;
const ll INF=0x3f3f3f3f,oo=0x3f3f3f3f3f3f3f3f;
const ldb eps=1e-6;
const ldb PI=acos(-1.0);
const int dir[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
template<typename T>
using vvector = vector<vector<T>>;

int main() {
    speed;
    int n,m;
    cin>>n>>m;
    vvector<bool> G(n+1,vector<bool>(n+1));
    for (int i=0;i<m;i++) {
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a][b]=true;
        G[b][a]=true;
    }
    vector<ll> dp((1<<n));
    vector<bool> pos((1<<n));
    for (int st=1;st<(1<<n);st++) {
        pos[st]=true;
        for (int a=0;a<n;a++) {
            for (int b=a+1;b<n;b++) {
                if (st&(1<<a) and st&(1<<b)) pos[st]=pos[st]&(!G[a][b]);
            }
        }
    }
    dp[0]=1;
    for (int st=1;st<(1<<n);st++) {
        dp[st]=0;
        for (int mask=st;;mask=(mask-1)&st) {
            if (mask==0) break;
            if (!pos[mask]) continue;
            dp[st]+=(__builtin_popcount(mask)&1?1:P-1)*dp[st^mask];
            dp[st]%=P;
        }
        // cout<<st<<" "<<dp[st]<<" st dp\n";
    }
    cout<<dp[(1<<n)-1]*m%P*((P+1)/2)%P<<"\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 504 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 504 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 504 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 504 KB Output is correct
33 Correct 1 ms 428 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 1 ms 504 KB Output is correct
38 Correct 1 ms 336 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Correct 1 ms 336 KB Output is correct
41 Correct 1 ms 336 KB Output is correct
42 Correct 1 ms 504 KB Output is correct
43 Correct 1 ms 336 KB Output is correct
44 Correct 1 ms 336 KB Output is correct
45 Correct 1 ms 336 KB Output is correct
46 Correct 1 ms 336 KB Output is correct
47 Correct 1 ms 336 KB Output is correct
48 Correct 1 ms 336 KB Output is correct
49 Correct 1 ms 336 KB Output is correct
50 Correct 1 ms 336 KB Output is correct
51 Correct 1 ms 336 KB Output is correct
52 Correct 1 ms 336 KB Output is correct
53 Correct 1 ms 336 KB Output is correct
54 Correct 1 ms 336 KB Output is correct
55 Correct 1 ms 336 KB Output is correct
56 Correct 1 ms 336 KB Output is correct
57 Correct 1 ms 336 KB Output is correct
58 Correct 1 ms 336 KB Output is correct
59 Correct 1 ms 336 KB Output is correct
60 Correct 1 ms 336 KB Output is correct
61 Correct 2 ms 336 KB Output is correct
62 Correct 1 ms 336 KB Output is correct
63 Correct 1 ms 336 KB Output is correct
64 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 504 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 504 KB Output is correct
33 Correct 1 ms 428 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 1 ms 504 KB Output is correct
38 Correct 1 ms 336 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Correct 1 ms 336 KB Output is correct
41 Correct 1 ms 336 KB Output is correct
42 Correct 1 ms 504 KB Output is correct
43 Correct 1 ms 336 KB Output is correct
44 Correct 1 ms 336 KB Output is correct
45 Correct 1 ms 336 KB Output is correct
46 Correct 1 ms 336 KB Output is correct
47 Correct 1 ms 336 KB Output is correct
48 Correct 1 ms 336 KB Output is correct
49 Correct 1 ms 336 KB Output is correct
50 Correct 1 ms 336 KB Output is correct
51 Correct 1 ms 336 KB Output is correct
52 Correct 1 ms 336 KB Output is correct
53 Correct 1 ms 336 KB Output is correct
54 Correct 1 ms 336 KB Output is correct
55 Correct 1 ms 336 KB Output is correct
56 Correct 1 ms 336 KB Output is correct
57 Correct 1 ms 336 KB Output is correct
58 Correct 1 ms 336 KB Output is correct
59 Correct 1 ms 336 KB Output is correct
60 Correct 1 ms 336 KB Output is correct
61 Correct 2 ms 336 KB Output is correct
62 Correct 1 ms 336 KB Output is correct
63 Correct 1 ms 336 KB Output is correct
64 Correct 1 ms 336 KB Output is correct
65 Correct 15 ms 592 KB Output is correct
66 Correct 14 ms 592 KB Output is correct
67 Correct 11 ms 588 KB Output is correct
68 Correct 11 ms 460 KB Output is correct
69 Correct 22 ms 760 KB Output is correct
70 Correct 16 ms 460 KB Output is correct
71 Correct 17 ms 592 KB Output is correct
72 Correct 18 ms 592 KB Output is correct
73 Correct 13 ms 460 KB Output is correct
74 Correct 15 ms 592 KB Output is correct
75 Correct 16 ms 592 KB Output is correct
76 Correct 15 ms 460 KB Output is correct
77 Correct 38 ms 592 KB Output is correct
78 Correct 31 ms 592 KB Output is correct
79 Correct 30 ms 592 KB Output is correct
80 Correct 29 ms 592 KB Output is correct
81 Correct 28 ms 592 KB Output is correct
82 Correct 27 ms 760 KB Output is correct
83 Correct 35 ms 592 KB Output is correct
84 Correct 26 ms 592 KB Output is correct
85 Correct 65 ms 592 KB Output is correct
86 Correct 47 ms 592 KB Output is correct
87 Correct 48 ms 592 KB Output is correct
88 Correct 52 ms 592 KB Output is correct
89 Correct 35 ms 592 KB Output is correct
90 Correct 37 ms 592 KB Output is correct
91 Correct 47 ms 592 KB Output is correct
92 Correct 41 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 504 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 504 KB Output is correct
33 Correct 1 ms 428 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 1 ms 504 KB Output is correct
38 Correct 1 ms 336 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Correct 1 ms 336 KB Output is correct
41 Correct 1 ms 336 KB Output is correct
42 Correct 1 ms 504 KB Output is correct
43 Correct 1 ms 336 KB Output is correct
44 Correct 1 ms 336 KB Output is correct
45 Correct 1 ms 336 KB Output is correct
46 Correct 1 ms 336 KB Output is correct
47 Correct 1 ms 336 KB Output is correct
48 Correct 1 ms 336 KB Output is correct
49 Correct 1 ms 336 KB Output is correct
50 Correct 1 ms 336 KB Output is correct
51 Correct 1 ms 336 KB Output is correct
52 Correct 1 ms 336 KB Output is correct
53 Correct 1 ms 336 KB Output is correct
54 Correct 1 ms 336 KB Output is correct
55 Correct 1 ms 336 KB Output is correct
56 Correct 1 ms 336 KB Output is correct
57 Correct 1 ms 336 KB Output is correct
58 Correct 1 ms 336 KB Output is correct
59 Correct 1 ms 336 KB Output is correct
60 Correct 1 ms 336 KB Output is correct
61 Correct 2 ms 336 KB Output is correct
62 Correct 1 ms 336 KB Output is correct
63 Correct 1 ms 336 KB Output is correct
64 Correct 1 ms 336 KB Output is correct
65 Correct 15 ms 592 KB Output is correct
66 Correct 14 ms 592 KB Output is correct
67 Correct 11 ms 588 KB Output is correct
68 Correct 11 ms 460 KB Output is correct
69 Correct 22 ms 760 KB Output is correct
70 Correct 16 ms 460 KB Output is correct
71 Correct 17 ms 592 KB Output is correct
72 Correct 18 ms 592 KB Output is correct
73 Correct 13 ms 460 KB Output is correct
74 Correct 15 ms 592 KB Output is correct
75 Correct 16 ms 592 KB Output is correct
76 Correct 15 ms 460 KB Output is correct
77 Correct 38 ms 592 KB Output is correct
78 Correct 31 ms 592 KB Output is correct
79 Correct 30 ms 592 KB Output is correct
80 Correct 29 ms 592 KB Output is correct
81 Correct 28 ms 592 KB Output is correct
82 Correct 27 ms 760 KB Output is correct
83 Correct 35 ms 592 KB Output is correct
84 Correct 26 ms 592 KB Output is correct
85 Correct 65 ms 592 KB Output is correct
86 Correct 47 ms 592 KB Output is correct
87 Correct 48 ms 592 KB Output is correct
88 Correct 52 ms 592 KB Output is correct
89 Correct 35 ms 592 KB Output is correct
90 Correct 37 ms 592 KB Output is correct
91 Correct 47 ms 592 KB Output is correct
92 Correct 41 ms 592 KB Output is correct
93 Correct 1156 ms 2384 KB Output is correct
94 Correct 1227 ms 2384 KB Output is correct
95 Correct 1178 ms 2384 KB Output is correct
96 Correct 968 ms 2384 KB Output is correct
97 Correct 837 ms 2384 KB Output is correct
98 Correct 945 ms 2384 KB Output is correct
99 Correct 99 ms 848 KB Output is correct
100 Correct 86 ms 848 KB Output is correct
101 Correct 80 ms 848 KB Output is correct
102 Correct 76 ms 848 KB Output is correct
103 Correct 759 ms 1360 KB Output is correct
104 Correct 421 ms 1360 KB Output is correct
105 Correct 334 ms 1360 KB Output is correct
106 Correct 275 ms 1532 KB Output is correct
107 Correct 2325 ms 2384 KB Output is correct
108 Correct 903 ms 2384 KB Output is correct
109 Correct 688 ms 2384 KB Output is correct
110 Correct 618 ms 2384 KB Output is correct
111 Correct 72 ms 848 KB Output is correct
112 Correct 79 ms 848 KB Output is correct
113 Correct 67 ms 848 KB Output is correct
114 Correct 182 ms 848 KB Output is correct
115 Correct 129 ms 848 KB Output is correct
116 Correct 137 ms 848 KB Output is correct
117 Correct 145 ms 1020 KB Output is correct
118 Correct 99 ms 848 KB Output is correct
119 Correct 104 ms 848 KB Output is correct
120 Correct 109 ms 848 KB Output is correct
121 Correct 117 ms 848 KB Output is correct
122 Correct 217 ms 1360 KB Output is correct
123 Correct 203 ms 1528 KB Output is correct
124 Correct 196 ms 1360 KB Output is correct
125 Correct 186 ms 1360 KB Output is correct
126 Correct 186 ms 1360 KB Output is correct
127 Correct 191 ms 1360 KB Output is correct
128 Correct 173 ms 1360 KB Output is correct
129 Correct 169 ms 1360 KB Output is correct
130 Correct 166 ms 1360 KB Output is correct
131 Correct 524 ms 1532 KB Output is correct
132 Correct 374 ms 1360 KB Output is correct
133 Correct 407 ms 1360 KB Output is correct
134 Correct 426 ms 1360 KB Output is correct
135 Correct 291 ms 1360 KB Output is correct
136 Correct 304 ms 1360 KB Output is correct
137 Correct 345 ms 1360 KB Output is correct
138 Correct 333 ms 1360 KB Output is correct
139 Correct 260 ms 1360 KB Output is correct
140 Correct 282 ms 1360 KB Output is correct
141 Correct 277 ms 1360 KB Output is correct
142 Correct 557 ms 2384 KB Output is correct
143 Correct 542 ms 2384 KB Output is correct
144 Correct 515 ms 2384 KB Output is correct
145 Correct 492 ms 2384 KB Output is correct
146 Correct 470 ms 2384 KB Output is correct
147 Correct 472 ms 2384 KB Output is correct
148 Correct 560 ms 2384 KB Output is correct
149 Correct 526 ms 2384 KB Output is correct
150 Correct 539 ms 2384 KB Output is correct
151 Correct 673 ms 2384 KB Output is correct
152 Correct 697 ms 2384 KB Output is correct
153 Correct 918 ms 2384 KB Output is correct
154 Correct 959 ms 2384 KB Output is correct
155 Correct 943 ms 2384 KB Output is correct
156 Correct 993 ms 2384 KB Output is correct
157 Correct 930 ms 2384 KB Output is correct
158 Correct 931 ms 2384 KB Output is correct
159 Correct 742 ms 2384 KB Output is correct
160 Correct 762 ms 2384 KB Output is correct
161 Correct 789 ms 2384 KB Output is correct
162 Correct 632 ms 2384 KB Output is correct
163 Correct 651 ms 2384 KB Output is correct
164 Correct 635 ms 2384 KB Output is correct
165 Correct 639 ms 2384 KB Output is correct
166 Correct 659 ms 2384 KB Output is correct
167 Correct 681 ms 2384 KB Output is correct