답안 #955857

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
955857 2024-03-31T15:33:35 Z Trisanu_Das Amusement Park (CEOI19_amusementpark) C++17
100 / 100
2894 ms 4728 KB
#include <bits/stdc++.h>
#define mod 998244353ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
using namespace std;
 
LL binpow(LL a,int n) {
	if(n==0) return 1;
	if(n%2==0) return binpow(a*a%mod,n/2);
	return a*binpow(a,n-1)%mod;
}
 
bool inMask(int a,int mask) {
	return (bool)((1<<a)&mask);
}
 
int n,m;
int ans[(1<<18)+10],cnt[(1<<18)+10];
vector<pair<int,int>> p;
vector<int> g[20];
bool isEdge[(1<<18)+10];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		g[a].PB(b);
		g[b].PB(a);
		p.PB(MP(a,b));
	}
 
	for(int mask=0;mask<(1<<n);mask++)
	{
		for(int i=0;i<n;i++)
		{
			if(((1<<i)&mask)==0)
				continue;
			cnt[mask]++;
			for(int j=0;j<g[i].size();j++)
				isEdge[mask]|=inMask(g[i][j],mask);
		}
	}
	ans[0]=1;
	for(int mask=1;mask<(1<<n);mask++) {
		int s=mask;
		vector<int> S;
		while(s){
			S.PB(s);
			s=(s-1)&mask;
		}
 
		while(!S.empty()) {
			s=S.back();
			S.pop_back();
			if(isEdge[s])
				continue;
			if(cnt[s]%2==1)
				ans[mask]+=ans[mask^s];
			else
				ans[mask]+=mod-ans[mask^s];
			ans[mask]%=mod;
		}
	}
 
	LL answ=ans[(1<<n)-1];
	answ*=(LL)m;
	answ%=mod;
	answ*=binpow(2,mod-2);
	answ%=mod;
 
	cout<<answ<<endl;
 
	return 0;
}

Compilation message

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:46:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |    for(int j=0;j<g[i].size();j++)
      |                ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2496 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2496 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct
33 Correct 1 ms 2392 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2392 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2392 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2392 KB Output is correct
46 Correct 1 ms 2392 KB Output is correct
47 Correct 1 ms 2400 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 1 ms 2396 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 1 ms 2396 KB Output is correct
52 Correct 1 ms 2392 KB Output is correct
53 Correct 1 ms 2392 KB Output is correct
54 Correct 1 ms 2392 KB Output is correct
55 Correct 1 ms 2396 KB Output is correct
56 Correct 1 ms 2396 KB Output is correct
57 Correct 1 ms 2396 KB Output is correct
58 Correct 1 ms 2396 KB Output is correct
59 Correct 1 ms 2396 KB Output is correct
60 Correct 1 ms 2396 KB Output is correct
61 Correct 1 ms 2396 KB Output is correct
62 Correct 1 ms 2396 KB Output is correct
63 Correct 1 ms 2396 KB Output is correct
64 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2496 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct
33 Correct 1 ms 2392 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2392 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2392 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2392 KB Output is correct
46 Correct 1 ms 2392 KB Output is correct
47 Correct 1 ms 2400 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 1 ms 2396 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 1 ms 2396 KB Output is correct
52 Correct 1 ms 2392 KB Output is correct
53 Correct 1 ms 2392 KB Output is correct
54 Correct 1 ms 2392 KB Output is correct
55 Correct 1 ms 2396 KB Output is correct
56 Correct 1 ms 2396 KB Output is correct
57 Correct 1 ms 2396 KB Output is correct
58 Correct 1 ms 2396 KB Output is correct
59 Correct 1 ms 2396 KB Output is correct
60 Correct 1 ms 2396 KB Output is correct
61 Correct 1 ms 2396 KB Output is correct
62 Correct 1 ms 2396 KB Output is correct
63 Correct 1 ms 2396 KB Output is correct
64 Correct 1 ms 2396 KB Output is correct
65 Correct 25 ms 2564 KB Output is correct
66 Correct 25 ms 2392 KB Output is correct
67 Correct 24 ms 2396 KB Output is correct
68 Correct 24 ms 2640 KB Output is correct
69 Correct 33 ms 2396 KB Output is correct
70 Correct 27 ms 2392 KB Output is correct
71 Correct 28 ms 2392 KB Output is correct
72 Correct 30 ms 2396 KB Output is correct
73 Correct 25 ms 2396 KB Output is correct
74 Correct 27 ms 2396 KB Output is correct
75 Correct 26 ms 2396 KB Output is correct
76 Correct 27 ms 2392 KB Output is correct
77 Correct 71 ms 2576 KB Output is correct
78 Correct 70 ms 2640 KB Output is correct
79 Correct 69 ms 2640 KB Output is correct
80 Correct 68 ms 2640 KB Output is correct
81 Correct 71 ms 2752 KB Output is correct
82 Correct 66 ms 2560 KB Output is correct
83 Correct 65 ms 2644 KB Output is correct
84 Correct 65 ms 2632 KB Output is correct
85 Correct 90 ms 2644 KB Output is correct
86 Correct 78 ms 2640 KB Output is correct
87 Correct 80 ms 2640 KB Output is correct
88 Correct 83 ms 2584 KB Output is correct
89 Correct 71 ms 2652 KB Output is correct
90 Correct 72 ms 2540 KB Output is correct
91 Correct 75 ms 2648 KB Output is correct
92 Correct 77 ms 2584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2496 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct
33 Correct 1 ms 2392 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2392 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2392 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2392 KB Output is correct
46 Correct 1 ms 2392 KB Output is correct
47 Correct 1 ms 2400 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 1 ms 2396 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 1 ms 2396 KB Output is correct
52 Correct 1 ms 2392 KB Output is correct
53 Correct 1 ms 2392 KB Output is correct
54 Correct 1 ms 2392 KB Output is correct
55 Correct 1 ms 2396 KB Output is correct
56 Correct 1 ms 2396 KB Output is correct
57 Correct 1 ms 2396 KB Output is correct
58 Correct 1 ms 2396 KB Output is correct
59 Correct 1 ms 2396 KB Output is correct
60 Correct 1 ms 2396 KB Output is correct
61 Correct 1 ms 2396 KB Output is correct
62 Correct 1 ms 2396 KB Output is correct
63 Correct 1 ms 2396 KB Output is correct
64 Correct 1 ms 2396 KB Output is correct
65 Correct 25 ms 2564 KB Output is correct
66 Correct 25 ms 2392 KB Output is correct
67 Correct 24 ms 2396 KB Output is correct
68 Correct 24 ms 2640 KB Output is correct
69 Correct 33 ms 2396 KB Output is correct
70 Correct 27 ms 2392 KB Output is correct
71 Correct 28 ms 2392 KB Output is correct
72 Correct 30 ms 2396 KB Output is correct
73 Correct 25 ms 2396 KB Output is correct
74 Correct 27 ms 2396 KB Output is correct
75 Correct 26 ms 2396 KB Output is correct
76 Correct 27 ms 2392 KB Output is correct
77 Correct 71 ms 2576 KB Output is correct
78 Correct 70 ms 2640 KB Output is correct
79 Correct 69 ms 2640 KB Output is correct
80 Correct 68 ms 2640 KB Output is correct
81 Correct 71 ms 2752 KB Output is correct
82 Correct 66 ms 2560 KB Output is correct
83 Correct 65 ms 2644 KB Output is correct
84 Correct 65 ms 2632 KB Output is correct
85 Correct 90 ms 2644 KB Output is correct
86 Correct 78 ms 2640 KB Output is correct
87 Correct 80 ms 2640 KB Output is correct
88 Correct 83 ms 2584 KB Output is correct
89 Correct 71 ms 2652 KB Output is correct
90 Correct 72 ms 2540 KB Output is correct
91 Correct 75 ms 2648 KB Output is correct
92 Correct 77 ms 2584 KB Output is correct
93 Correct 2044 ms 4128 KB Output is correct
94 Correct 2065 ms 4216 KB Output is correct
95 Correct 2094 ms 4172 KB Output is correct
96 Correct 1857 ms 4064 KB Output is correct
97 Correct 1837 ms 4148 KB Output is correct
98 Correct 1878 ms 4144 KB Output is correct
99 Correct 214 ms 2908 KB Output is correct
100 Correct 212 ms 2820 KB Output is correct
101 Correct 200 ms 3076 KB Output is correct
102 Correct 198 ms 2816 KB Output is correct
103 Correct 974 ms 3152 KB Output is correct
104 Correct 711 ms 3296 KB Output is correct
105 Correct 647 ms 3348 KB Output is correct
106 Correct 590 ms 3128 KB Output is correct
107 Correct 2894 ms 4728 KB Output is correct
108 Correct 1878 ms 4268 KB Output is correct
109 Correct 1718 ms 4248 KB Output is correct
110 Correct 1669 ms 4284 KB Output is correct
111 Correct 192 ms 2884 KB Output is correct
112 Correct 189 ms 2904 KB Output is correct
113 Correct 189 ms 2880 KB Output is correct
114 Correct 264 ms 2836 KB Output is correct
115 Correct 233 ms 2820 KB Output is correct
116 Correct 235 ms 2820 KB Output is correct
117 Correct 245 ms 2848 KB Output is correct
118 Correct 212 ms 2840 KB Output is correct
119 Correct 211 ms 2816 KB Output is correct
120 Correct 215 ms 2816 KB Output is correct
121 Correct 224 ms 2844 KB Output is correct
122 Correct 579 ms 3124 KB Output is correct
123 Correct 559 ms 3340 KB Output is correct
124 Correct 553 ms 3252 KB Output is correct
125 Correct 543 ms 3248 KB Output is correct
126 Correct 541 ms 3368 KB Output is correct
127 Correct 545 ms 3352 KB Output is correct
128 Correct 531 ms 3372 KB Output is correct
129 Correct 533 ms 3420 KB Output is correct
130 Correct 527 ms 3620 KB Output is correct
131 Correct 789 ms 3312 KB Output is correct
132 Correct 737 ms 3536 KB Output is correct
133 Correct 701 ms 3124 KB Output is correct
134 Correct 719 ms 3376 KB Output is correct
135 Correct 637 ms 3292 KB Output is correct
136 Correct 632 ms 3328 KB Output is correct
137 Correct 640 ms 3800 KB Output is correct
138 Correct 658 ms 3432 KB Output is correct
139 Correct 581 ms 3376 KB Output is correct
140 Correct 608 ms 3472 KB Output is correct
141 Correct 608 ms 3608 KB Output is correct
142 Correct 1620 ms 4240 KB Output is correct
143 Correct 1593 ms 4412 KB Output is correct
144 Correct 1582 ms 4376 KB Output is correct
145 Correct 1566 ms 4564 KB Output is correct
146 Correct 1544 ms 4204 KB Output is correct
147 Correct 1530 ms 4340 KB Output is correct
148 Correct 1633 ms 4176 KB Output is correct
149 Correct 1616 ms 4164 KB Output is correct
150 Correct 1616 ms 4316 KB Output is correct
151 Correct 1710 ms 4384 KB Output is correct
152 Correct 1697 ms 4376 KB Output is correct
153 Correct 1892 ms 4392 KB Output is correct
154 Correct 1851 ms 4164 KB Output is correct
155 Correct 1910 ms 4384 KB Output is correct
156 Correct 1920 ms 4512 KB Output is correct
157 Correct 1895 ms 4196 KB Output is correct
158 Correct 1896 ms 4316 KB Output is correct
159 Correct 1770 ms 4156 KB Output is correct
160 Correct 1753 ms 4468 KB Output is correct
161 Correct 1799 ms 4372 KB Output is correct
162 Correct 1672 ms 4420 KB Output is correct
163 Correct 1654 ms 4380 KB Output is correct
164 Correct 1659 ms 4268 KB Output is correct
165 Correct 1665 ms 4640 KB Output is correct
166 Correct 1688 ms 4548 KB Output is correct
167 Correct 1714 ms 4368 KB Output is correct