답안 #583533

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
583533 2022-06-25T14:08:45 Z urd05 Amusement Park (CEOI19_amusementpark) C++17
100 / 100
1890 ms 3568 KB
#include <bits/stdc++.h>
using namespace std;

int n,m;
bool arr[18][18];
const int mod=998244353;
long long dp[262144];
int p[262144];

int main() {
    scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++) {
        int u,v;
        scanf("%d %d",&u,&v);
        u--;
        v--;
        arr[u][v]=true;
    }
    memset(p,-1,sizeof(p));
    for(int i=0;i<(1<<n);i++) {
        int cnt=0;
        for(int j=0;j<n;j++) {
            if (i&(1<<j)) {
                cnt++;
            }
        }
        for(int j=0;j<n;j++) {
            for(int k=0;k<n;k++) {
                if (i&(1<<j)) {
                    if (i&(1<<k)) {
                        if (arr[j][k]||arr[k][j]) {
                            p[i]=0;
                            break;
                        }
                    }
                }
            }
        }
        if (cnt%2==1) {
            p[i]=(mod-p[i])%mod;
        }
        else {
            p[i]=(mod+p[i])%mod;
        }
    }
    dp[0]=1;
    for(int i=1;i<(1<<n);i++) {
        int msk=i;
        for(int j=i;j;j=((j-1)&i)) {
            dp[i]+=dp[j^i]*p[j];
            dp[i]%=mod;
        }
    }
    long long ret=dp[(1<<n)-1];
    ret*=m;
    ret%=mod;
    ret*=(mod+1)/2;
    ret%=mod;
    printf("%lld",ret);
    return 0;
}

Compilation message

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:48:13: warning: unused variable 'msk' [-Wunused-variable]
   48 |         int msk=i;
      |             ^~~
amusementpark.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d %d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~
amusementpark.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf("%d %d",&u,&v);
      |         ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 1236 KB Output is correct
3 Correct 1 ms 1236 KB Output is correct
4 Correct 1 ms 1236 KB Output is correct
5 Correct 1 ms 1236 KB Output is correct
6 Correct 1 ms 1236 KB Output is correct
7 Correct 1 ms 1236 KB Output is correct
8 Correct 1 ms 1236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 1236 KB Output is correct
3 Correct 1 ms 1236 KB Output is correct
4 Correct 1 ms 1236 KB Output is correct
5 Correct 1 ms 1236 KB Output is correct
6 Correct 1 ms 1236 KB Output is correct
7 Correct 1 ms 1236 KB Output is correct
8 Correct 1 ms 1236 KB Output is correct
9 Correct 3 ms 1236 KB Output is correct
10 Correct 1 ms 1236 KB Output is correct
11 Correct 1 ms 1320 KB Output is correct
12 Correct 1 ms 1236 KB Output is correct
13 Correct 1 ms 1236 KB Output is correct
14 Correct 1 ms 1236 KB Output is correct
15 Correct 1 ms 1236 KB Output is correct
16 Correct 1 ms 1236 KB Output is correct
17 Correct 1 ms 1236 KB Output is correct
18 Correct 1 ms 1236 KB Output is correct
19 Correct 1 ms 1236 KB Output is correct
20 Correct 1 ms 1236 KB Output is correct
21 Correct 1 ms 1236 KB Output is correct
22 Correct 1 ms 1236 KB Output is correct
23 Correct 1 ms 1236 KB Output is correct
24 Correct 1 ms 1236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 1236 KB Output is correct
3 Correct 1 ms 1236 KB Output is correct
4 Correct 1 ms 1236 KB Output is correct
5 Correct 1 ms 1236 KB Output is correct
6 Correct 1 ms 1236 KB Output is correct
7 Correct 1 ms 1236 KB Output is correct
8 Correct 1 ms 1236 KB Output is correct
9 Correct 3 ms 1236 KB Output is correct
10 Correct 1 ms 1236 KB Output is correct
11 Correct 1 ms 1320 KB Output is correct
12 Correct 1 ms 1236 KB Output is correct
13 Correct 1 ms 1236 KB Output is correct
14 Correct 1 ms 1236 KB Output is correct
15 Correct 1 ms 1236 KB Output is correct
16 Correct 1 ms 1236 KB Output is correct
17 Correct 1 ms 1236 KB Output is correct
18 Correct 1 ms 1236 KB Output is correct
19 Correct 1 ms 1236 KB Output is correct
20 Correct 1 ms 1236 KB Output is correct
21 Correct 1 ms 1236 KB Output is correct
22 Correct 1 ms 1236 KB Output is correct
23 Correct 1 ms 1236 KB Output is correct
24 Correct 1 ms 1236 KB Output is correct
25 Correct 1 ms 1236 KB Output is correct
26 Correct 1 ms 1236 KB Output is correct
27 Correct 2 ms 1308 KB Output is correct
28 Correct 1 ms 1236 KB Output is correct
29 Correct 1 ms 1236 KB Output is correct
30 Correct 1 ms 1236 KB Output is correct
31 Correct 1 ms 1236 KB Output is correct
32 Correct 1 ms 1236 KB Output is correct
33 Correct 1 ms 1236 KB Output is correct
34 Correct 1 ms 1236 KB Output is correct
35 Correct 1 ms 1236 KB Output is correct
36 Correct 1 ms 1236 KB Output is correct
37 Correct 1 ms 1236 KB Output is correct
38 Correct 1 ms 1236 KB Output is correct
39 Correct 1 ms 1236 KB Output is correct
40 Correct 1 ms 1236 KB Output is correct
41 Correct 1 ms 1236 KB Output is correct
42 Correct 1 ms 1236 KB Output is correct
43 Correct 1 ms 1236 KB Output is correct
44 Correct 1 ms 1236 KB Output is correct
45 Correct 1 ms 1236 KB Output is correct
46 Correct 2 ms 1236 KB Output is correct
47 Correct 1 ms 1236 KB Output is correct
48 Correct 1 ms 1236 KB Output is correct
49 Correct 1 ms 1236 KB Output is correct
50 Correct 2 ms 1236 KB Output is correct
51 Correct 1 ms 1236 KB Output is correct
52 Correct 1 ms 1236 KB Output is correct
53 Correct 1 ms 1236 KB Output is correct
54 Correct 1 ms 1236 KB Output is correct
55 Correct 1 ms 1236 KB Output is correct
56 Correct 1 ms 1236 KB Output is correct
57 Correct 1 ms 1236 KB Output is correct
58 Correct 1 ms 1336 KB Output is correct
59 Correct 1 ms 1236 KB Output is correct
60 Correct 2 ms 1340 KB Output is correct
61 Correct 1 ms 1236 KB Output is correct
62 Correct 1 ms 1332 KB Output is correct
63 Correct 1 ms 1236 KB Output is correct
64 Correct 1 ms 1236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 1236 KB Output is correct
3 Correct 1 ms 1236 KB Output is correct
4 Correct 1 ms 1236 KB Output is correct
5 Correct 1 ms 1236 KB Output is correct
6 Correct 1 ms 1236 KB Output is correct
7 Correct 1 ms 1236 KB Output is correct
8 Correct 1 ms 1236 KB Output is correct
9 Correct 3 ms 1236 KB Output is correct
10 Correct 1 ms 1236 KB Output is correct
11 Correct 1 ms 1320 KB Output is correct
12 Correct 1 ms 1236 KB Output is correct
13 Correct 1 ms 1236 KB Output is correct
14 Correct 1 ms 1236 KB Output is correct
15 Correct 1 ms 1236 KB Output is correct
16 Correct 1 ms 1236 KB Output is correct
17 Correct 1 ms 1236 KB Output is correct
18 Correct 1 ms 1236 KB Output is correct
19 Correct 1 ms 1236 KB Output is correct
20 Correct 1 ms 1236 KB Output is correct
21 Correct 1 ms 1236 KB Output is correct
22 Correct 1 ms 1236 KB Output is correct
23 Correct 1 ms 1236 KB Output is correct
24 Correct 1 ms 1236 KB Output is correct
25 Correct 1 ms 1236 KB Output is correct
26 Correct 1 ms 1236 KB Output is correct
27 Correct 2 ms 1308 KB Output is correct
28 Correct 1 ms 1236 KB Output is correct
29 Correct 1 ms 1236 KB Output is correct
30 Correct 1 ms 1236 KB Output is correct
31 Correct 1 ms 1236 KB Output is correct
32 Correct 1 ms 1236 KB Output is correct
33 Correct 1 ms 1236 KB Output is correct
34 Correct 1 ms 1236 KB Output is correct
35 Correct 1 ms 1236 KB Output is correct
36 Correct 1 ms 1236 KB Output is correct
37 Correct 1 ms 1236 KB Output is correct
38 Correct 1 ms 1236 KB Output is correct
39 Correct 1 ms 1236 KB Output is correct
40 Correct 1 ms 1236 KB Output is correct
41 Correct 1 ms 1236 KB Output is correct
42 Correct 1 ms 1236 KB Output is correct
43 Correct 1 ms 1236 KB Output is correct
44 Correct 1 ms 1236 KB Output is correct
45 Correct 1 ms 1236 KB Output is correct
46 Correct 2 ms 1236 KB Output is correct
47 Correct 1 ms 1236 KB Output is correct
48 Correct 1 ms 1236 KB Output is correct
49 Correct 1 ms 1236 KB Output is correct
50 Correct 2 ms 1236 KB Output is correct
51 Correct 1 ms 1236 KB Output is correct
52 Correct 1 ms 1236 KB Output is correct
53 Correct 1 ms 1236 KB Output is correct
54 Correct 1 ms 1236 KB Output is correct
55 Correct 1 ms 1236 KB Output is correct
56 Correct 1 ms 1236 KB Output is correct
57 Correct 1 ms 1236 KB Output is correct
58 Correct 1 ms 1336 KB Output is correct
59 Correct 1 ms 1236 KB Output is correct
60 Correct 2 ms 1340 KB Output is correct
61 Correct 1 ms 1236 KB Output is correct
62 Correct 1 ms 1332 KB Output is correct
63 Correct 1 ms 1236 KB Output is correct
64 Correct 1 ms 1236 KB Output is correct
65 Correct 26 ms 1452 KB Output is correct
66 Correct 26 ms 1384 KB Output is correct
67 Correct 26 ms 1452 KB Output is correct
68 Correct 24 ms 1448 KB Output is correct
69 Correct 24 ms 1424 KB Output is correct
70 Correct 22 ms 1364 KB Output is correct
71 Correct 24 ms 1452 KB Output is correct
72 Correct 28 ms 1444 KB Output is correct
73 Correct 23 ms 1364 KB Output is correct
74 Correct 24 ms 1428 KB Output is correct
75 Correct 25 ms 1420 KB Output is correct
76 Correct 25 ms 1440 KB Output is correct
77 Correct 73 ms 1452 KB Output is correct
78 Correct 72 ms 1460 KB Output is correct
79 Correct 72 ms 1780 KB Output is correct
80 Correct 68 ms 1560 KB Output is correct
81 Correct 73 ms 1520 KB Output is correct
82 Correct 67 ms 1572 KB Output is correct
83 Correct 68 ms 1520 KB Output is correct
84 Correct 66 ms 1556 KB Output is correct
85 Correct 71 ms 1524 KB Output is correct
86 Correct 74 ms 1548 KB Output is correct
87 Correct 75 ms 1612 KB Output is correct
88 Correct 74 ms 1548 KB Output is correct
89 Correct 65 ms 1564 KB Output is correct
90 Correct 67 ms 1580 KB Output is correct
91 Correct 67 ms 1564 KB Output is correct
92 Correct 71 ms 1628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 1236 KB Output is correct
3 Correct 1 ms 1236 KB Output is correct
4 Correct 1 ms 1236 KB Output is correct
5 Correct 1 ms 1236 KB Output is correct
6 Correct 1 ms 1236 KB Output is correct
7 Correct 1 ms 1236 KB Output is correct
8 Correct 1 ms 1236 KB Output is correct
9 Correct 3 ms 1236 KB Output is correct
10 Correct 1 ms 1236 KB Output is correct
11 Correct 1 ms 1320 KB Output is correct
12 Correct 1 ms 1236 KB Output is correct
13 Correct 1 ms 1236 KB Output is correct
14 Correct 1 ms 1236 KB Output is correct
15 Correct 1 ms 1236 KB Output is correct
16 Correct 1 ms 1236 KB Output is correct
17 Correct 1 ms 1236 KB Output is correct
18 Correct 1 ms 1236 KB Output is correct
19 Correct 1 ms 1236 KB Output is correct
20 Correct 1 ms 1236 KB Output is correct
21 Correct 1 ms 1236 KB Output is correct
22 Correct 1 ms 1236 KB Output is correct
23 Correct 1 ms 1236 KB Output is correct
24 Correct 1 ms 1236 KB Output is correct
25 Correct 1 ms 1236 KB Output is correct
26 Correct 1 ms 1236 KB Output is correct
27 Correct 2 ms 1308 KB Output is correct
28 Correct 1 ms 1236 KB Output is correct
29 Correct 1 ms 1236 KB Output is correct
30 Correct 1 ms 1236 KB Output is correct
31 Correct 1 ms 1236 KB Output is correct
32 Correct 1 ms 1236 KB Output is correct
33 Correct 1 ms 1236 KB Output is correct
34 Correct 1 ms 1236 KB Output is correct
35 Correct 1 ms 1236 KB Output is correct
36 Correct 1 ms 1236 KB Output is correct
37 Correct 1 ms 1236 KB Output is correct
38 Correct 1 ms 1236 KB Output is correct
39 Correct 1 ms 1236 KB Output is correct
40 Correct 1 ms 1236 KB Output is correct
41 Correct 1 ms 1236 KB Output is correct
42 Correct 1 ms 1236 KB Output is correct
43 Correct 1 ms 1236 KB Output is correct
44 Correct 1 ms 1236 KB Output is correct
45 Correct 1 ms 1236 KB Output is correct
46 Correct 2 ms 1236 KB Output is correct
47 Correct 1 ms 1236 KB Output is correct
48 Correct 1 ms 1236 KB Output is correct
49 Correct 1 ms 1236 KB Output is correct
50 Correct 2 ms 1236 KB Output is correct
51 Correct 1 ms 1236 KB Output is correct
52 Correct 1 ms 1236 KB Output is correct
53 Correct 1 ms 1236 KB Output is correct
54 Correct 1 ms 1236 KB Output is correct
55 Correct 1 ms 1236 KB Output is correct
56 Correct 1 ms 1236 KB Output is correct
57 Correct 1 ms 1236 KB Output is correct
58 Correct 1 ms 1336 KB Output is correct
59 Correct 1 ms 1236 KB Output is correct
60 Correct 2 ms 1340 KB Output is correct
61 Correct 1 ms 1236 KB Output is correct
62 Correct 1 ms 1332 KB Output is correct
63 Correct 1 ms 1236 KB Output is correct
64 Correct 1 ms 1236 KB Output is correct
65 Correct 26 ms 1452 KB Output is correct
66 Correct 26 ms 1384 KB Output is correct
67 Correct 26 ms 1452 KB Output is correct
68 Correct 24 ms 1448 KB Output is correct
69 Correct 24 ms 1424 KB Output is correct
70 Correct 22 ms 1364 KB Output is correct
71 Correct 24 ms 1452 KB Output is correct
72 Correct 28 ms 1444 KB Output is correct
73 Correct 23 ms 1364 KB Output is correct
74 Correct 24 ms 1428 KB Output is correct
75 Correct 25 ms 1420 KB Output is correct
76 Correct 25 ms 1440 KB Output is correct
77 Correct 73 ms 1452 KB Output is correct
78 Correct 72 ms 1460 KB Output is correct
79 Correct 72 ms 1780 KB Output is correct
80 Correct 68 ms 1560 KB Output is correct
81 Correct 73 ms 1520 KB Output is correct
82 Correct 67 ms 1572 KB Output is correct
83 Correct 68 ms 1520 KB Output is correct
84 Correct 66 ms 1556 KB Output is correct
85 Correct 71 ms 1524 KB Output is correct
86 Correct 74 ms 1548 KB Output is correct
87 Correct 75 ms 1612 KB Output is correct
88 Correct 74 ms 1548 KB Output is correct
89 Correct 65 ms 1564 KB Output is correct
90 Correct 67 ms 1580 KB Output is correct
91 Correct 67 ms 1564 KB Output is correct
92 Correct 71 ms 1628 KB Output is correct
93 Correct 1636 ms 3424 KB Output is correct
94 Correct 1623 ms 3540 KB Output is correct
95 Correct 1814 ms 3296 KB Output is correct
96 Correct 1637 ms 3352 KB Output is correct
97 Correct 1890 ms 3296 KB Output is correct
98 Correct 1703 ms 3356 KB Output is correct
99 Correct 201 ms 1788 KB Output is correct
100 Correct 203 ms 1824 KB Output is correct
101 Correct 199 ms 1824 KB Output is correct
102 Correct 204 ms 1724 KB Output is correct
103 Correct 600 ms 2324 KB Output is correct
104 Correct 612 ms 2408 KB Output is correct
105 Correct 592 ms 2316 KB Output is correct
106 Correct 653 ms 2324 KB Output is correct
107 Correct 1768 ms 3356 KB Output is correct
108 Correct 1772 ms 3268 KB Output is correct
109 Correct 1705 ms 3424 KB Output is correct
110 Correct 1678 ms 3472 KB Output is correct
111 Correct 201 ms 1816 KB Output is correct
112 Correct 191 ms 1720 KB Output is correct
113 Correct 225 ms 1760 KB Output is correct
114 Correct 202 ms 1820 KB Output is correct
115 Correct 193 ms 1812 KB Output is correct
116 Correct 204 ms 1792 KB Output is correct
117 Correct 206 ms 1704 KB Output is correct
118 Correct 192 ms 1872 KB Output is correct
119 Correct 193 ms 1820 KB Output is correct
120 Correct 200 ms 1740 KB Output is correct
121 Correct 202 ms 1868 KB Output is correct
122 Correct 555 ms 2464 KB Output is correct
123 Correct 568 ms 2324 KB Output is correct
124 Correct 568 ms 2404 KB Output is correct
125 Correct 565 ms 2436 KB Output is correct
126 Correct 562 ms 2308 KB Output is correct
127 Correct 556 ms 2324 KB Output is correct
128 Correct 546 ms 2460 KB Output is correct
129 Correct 578 ms 2328 KB Output is correct
130 Correct 542 ms 2392 KB Output is correct
131 Correct 563 ms 2560 KB Output is correct
132 Correct 614 ms 2456 KB Output is correct
133 Correct 581 ms 2268 KB Output is correct
134 Correct 555 ms 2352 KB Output is correct
135 Correct 522 ms 2344 KB Output is correct
136 Correct 535 ms 2220 KB Output is correct
137 Correct 557 ms 2400 KB Output is correct
138 Correct 550 ms 2336 KB Output is correct
139 Correct 523 ms 2412 KB Output is correct
140 Correct 544 ms 2332 KB Output is correct
141 Correct 548 ms 2252 KB Output is correct
142 Correct 1578 ms 3344 KB Output is correct
143 Correct 1595 ms 3516 KB Output is correct
144 Correct 1535 ms 3360 KB Output is correct
145 Correct 1520 ms 3508 KB Output is correct
146 Correct 1526 ms 3464 KB Output is correct
147 Correct 1527 ms 3404 KB Output is correct
148 Correct 1551 ms 3408 KB Output is correct
149 Correct 1583 ms 3568 KB Output is correct
150 Correct 1535 ms 3360 KB Output is correct
151 Correct 1578 ms 3520 KB Output is correct
152 Correct 1585 ms 3532 KB Output is correct
153 Correct 1546 ms 3552 KB Output is correct
154 Correct 1516 ms 3556 KB Output is correct
155 Correct 1541 ms 3444 KB Output is correct
156 Correct 1615 ms 3516 KB Output is correct
157 Correct 1586 ms 3432 KB Output is correct
158 Correct 1570 ms 3556 KB Output is correct
159 Correct 1531 ms 3388 KB Output is correct
160 Correct 1560 ms 3484 KB Output is correct
161 Correct 1605 ms 3440 KB Output is correct
162 Correct 1555 ms 3284 KB Output is correct
163 Correct 1545 ms 3388 KB Output is correct
164 Correct 1542 ms 3328 KB Output is correct
165 Correct 1562 ms 3544 KB Output is correct
166 Correct 1561 ms 3336 KB Output is correct
167 Correct 1617 ms 3364 KB Output is correct