답안 #650377

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
650377 2022-10-13T15:44:11 Z daria Amusement Park (CEOI19_amusementpark) C++14
100 / 100
2573 ms 4556 KB
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define _ << " " <<
typedef pair<int, int> pii;
typedef array<int, 3> tii;

const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 998244353;

int main(){
 int n, m; cin >> n >> m;
 const int N = (1 << n);
 vector<vector<bool> > adj(n, vector<bool> (n, 0));
 vector<ll> cnt(N, 0), res(N, 0);
 for(int i = 0; i<m; ++i){
  int a, b; cin >> a >> b; a--; b--;
  adj[a][b] = adj[b][a] = 1;
 }
 vector<bool> indset(N, 1);
 for(int i=0; i<N; ++i)
  for(int j=0; j<n; ++j)
   cnt[i] += (!!((1<<j)&i));
 for(int i=0; i<N; ++i)
  for(int j=0; j<min(n, i); ++j)
   for(int k=0; k<j; ++k)
    if(adj[j][k] & !!(1&(i>>j)) & !!(1&(i>>k)))
     indset[i] = 0;
 res[0] = 1;
 for(int i=1; i<N; ++i){
  for(int j = i; j; j = (i&(j-1))){
   if(cnt[j]%2) res[i] = (res[i] + indset[j]*res[i^j])%mod;
   else res[i] = (res[i] + mod - indset[j]*res[i^j])%mod;
  }
 }
 ll ans = ((res[N-1] + mod)*m)%mod;
 ans = (ans*(mod+1)/2)%mod;
 cout << ans << endl;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 0 ms 292 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 0 ms 292 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 296 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 296 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 0 ms 292 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 296 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 296 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 296 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 300 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 296 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 304 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 296 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 300 KB Output is correct
49 Correct 1 ms 300 KB Output is correct
50 Correct 1 ms 300 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 1 ms 212 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 ms 300 KB Output is correct
58 Correct 1 ms 300 KB Output is correct
59 Correct 2 ms 212 KB Output is correct
60 Correct 2 ms 212 KB Output is correct
61 Correct 1 ms 304 KB Output is correct
62 Correct 1 ms 212 KB Output is correct
63 Correct 1 ms 212 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 0 ms 292 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 296 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 296 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 296 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 300 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 296 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 304 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 296 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 300 KB Output is correct
49 Correct 1 ms 300 KB Output is correct
50 Correct 1 ms 300 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 1 ms 212 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 ms 300 KB Output is correct
58 Correct 1 ms 300 KB Output is correct
59 Correct 2 ms 212 KB Output is correct
60 Correct 2 ms 212 KB Output is correct
61 Correct 1 ms 304 KB Output is correct
62 Correct 1 ms 212 KB Output is correct
63 Correct 1 ms 212 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 34 ms 592 KB Output is correct
66 Correct 34 ms 560 KB Output is correct
67 Correct 34 ms 468 KB Output is correct
68 Correct 36 ms 468 KB Output is correct
69 Correct 34 ms 556 KB Output is correct
70 Correct 33 ms 560 KB Output is correct
71 Correct 34 ms 468 KB Output is correct
72 Correct 35 ms 468 KB Output is correct
73 Correct 34 ms 560 KB Output is correct
74 Correct 34 ms 468 KB Output is correct
75 Correct 33 ms 468 KB Output is correct
76 Correct 33 ms 556 KB Output is correct
77 Correct 95 ms 724 KB Output is correct
78 Correct 99 ms 816 KB Output is correct
79 Correct 98 ms 820 KB Output is correct
80 Correct 98 ms 816 KB Output is correct
81 Correct 97 ms 820 KB Output is correct
82 Correct 100 ms 724 KB Output is correct
83 Correct 100 ms 816 KB Output is correct
84 Correct 100 ms 816 KB Output is correct
85 Correct 95 ms 932 KB Output is correct
86 Correct 96 ms 820 KB Output is correct
87 Correct 95 ms 816 KB Output is correct
88 Correct 96 ms 820 KB Output is correct
89 Correct 98 ms 724 KB Output is correct
90 Correct 97 ms 816 KB Output is correct
91 Correct 97 ms 724 KB Output is correct
92 Correct 98 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 0 ms 292 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 296 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 296 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 296 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 300 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 296 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 304 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 296 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 300 KB Output is correct
49 Correct 1 ms 300 KB Output is correct
50 Correct 1 ms 300 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 1 ms 212 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 ms 300 KB Output is correct
58 Correct 1 ms 300 KB Output is correct
59 Correct 2 ms 212 KB Output is correct
60 Correct 2 ms 212 KB Output is correct
61 Correct 1 ms 304 KB Output is correct
62 Correct 1 ms 212 KB Output is correct
63 Correct 1 ms 212 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 34 ms 592 KB Output is correct
66 Correct 34 ms 560 KB Output is correct
67 Correct 34 ms 468 KB Output is correct
68 Correct 36 ms 468 KB Output is correct
69 Correct 34 ms 556 KB Output is correct
70 Correct 33 ms 560 KB Output is correct
71 Correct 34 ms 468 KB Output is correct
72 Correct 35 ms 468 KB Output is correct
73 Correct 34 ms 560 KB Output is correct
74 Correct 34 ms 468 KB Output is correct
75 Correct 33 ms 468 KB Output is correct
76 Correct 33 ms 556 KB Output is correct
77 Correct 95 ms 724 KB Output is correct
78 Correct 99 ms 816 KB Output is correct
79 Correct 98 ms 820 KB Output is correct
80 Correct 98 ms 816 KB Output is correct
81 Correct 97 ms 820 KB Output is correct
82 Correct 100 ms 724 KB Output is correct
83 Correct 100 ms 816 KB Output is correct
84 Correct 100 ms 816 KB Output is correct
85 Correct 95 ms 932 KB Output is correct
86 Correct 96 ms 820 KB Output is correct
87 Correct 95 ms 816 KB Output is correct
88 Correct 96 ms 820 KB Output is correct
89 Correct 98 ms 724 KB Output is correct
90 Correct 97 ms 816 KB Output is correct
91 Correct 97 ms 724 KB Output is correct
92 Correct 98 ms 724 KB Output is correct
93 Correct 2494 ms 4436 KB Output is correct
94 Correct 2497 ms 4436 KB Output is correct
95 Correct 2471 ms 4436 KB Output is correct
96 Correct 2522 ms 4436 KB Output is correct
97 Correct 2482 ms 4436 KB Output is correct
98 Correct 2526 ms 4436 KB Output is correct
99 Correct 282 ms 1332 KB Output is correct
100 Correct 283 ms 1332 KB Output is correct
101 Correct 280 ms 1332 KB Output is correct
102 Correct 283 ms 1328 KB Output is correct
103 Correct 845 ms 2364 KB Output is correct
104 Correct 847 ms 2364 KB Output is correct
105 Correct 834 ms 2388 KB Output is correct
106 Correct 837 ms 2368 KB Output is correct
107 Correct 2495 ms 4436 KB Output is correct
108 Correct 2502 ms 4444 KB Output is correct
109 Correct 2454 ms 4556 KB Output is correct
110 Correct 2503 ms 4556 KB Output is correct
111 Correct 289 ms 1336 KB Output is correct
112 Correct 285 ms 1332 KB Output is correct
113 Correct 292 ms 1236 KB Output is correct
114 Correct 278 ms 1336 KB Output is correct
115 Correct 287 ms 1236 KB Output is correct
116 Correct 291 ms 1336 KB Output is correct
117 Correct 287 ms 1332 KB Output is correct
118 Correct 280 ms 1236 KB Output is correct
119 Correct 285 ms 1336 KB Output is correct
120 Correct 286 ms 1340 KB Output is correct
121 Correct 279 ms 1356 KB Output is correct
122 Correct 832 ms 2380 KB Output is correct
123 Correct 859 ms 2364 KB Output is correct
124 Correct 857 ms 2364 KB Output is correct
125 Correct 848 ms 2260 KB Output is correct
126 Correct 851 ms 2260 KB Output is correct
127 Correct 851 ms 2380 KB Output is correct
128 Correct 859 ms 2260 KB Output is correct
129 Correct 863 ms 2380 KB Output is correct
130 Correct 866 ms 2380 KB Output is correct
131 Correct 836 ms 2364 KB Output is correct
132 Correct 852 ms 2260 KB Output is correct
133 Correct 861 ms 2260 KB Output is correct
134 Correct 854 ms 2364 KB Output is correct
135 Correct 851 ms 2252 KB Output is correct
136 Correct 847 ms 2380 KB Output is correct
137 Correct 833 ms 2352 KB Output is correct
138 Correct 843 ms 2388 KB Output is correct
139 Correct 845 ms 2388 KB Output is correct
140 Correct 850 ms 2388 KB Output is correct
141 Correct 846 ms 2368 KB Output is correct
142 Correct 2508 ms 4448 KB Output is correct
143 Correct 2507 ms 4436 KB Output is correct
144 Correct 2507 ms 4440 KB Output is correct
145 Correct 2557 ms 4556 KB Output is correct
146 Correct 2556 ms 4436 KB Output is correct
147 Correct 2528 ms 4436 KB Output is correct
148 Correct 2488 ms 4456 KB Output is correct
149 Correct 2498 ms 4436 KB Output is correct
150 Correct 2521 ms 4436 KB Output is correct
151 Correct 2496 ms 4448 KB Output is correct
152 Correct 2452 ms 4556 KB Output is correct
153 Correct 2474 ms 4452 KB Output is correct
154 Correct 2466 ms 4436 KB Output is correct
155 Correct 2469 ms 4436 KB Output is correct
156 Correct 2482 ms 4444 KB Output is correct
157 Correct 2513 ms 4556 KB Output is correct
158 Correct 2539 ms 4436 KB Output is correct
159 Correct 2551 ms 4436 KB Output is correct
160 Correct 2573 ms 4436 KB Output is correct
161 Correct 2505 ms 4556 KB Output is correct
162 Correct 2509 ms 4436 KB Output is correct
163 Correct 2472 ms 4436 KB Output is correct
164 Correct 2474 ms 4436 KB Output is correct
165 Correct 2474 ms 4436 KB Output is correct
166 Correct 2455 ms 4436 KB Output is correct
167 Correct 2443 ms 4556 KB Output is correct