/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <stack>
#include <cassert>
#include <iterator>
#include <bitset>
#include <fstream>
#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 i=0;i<n;i++)
// ans[(1<<i)]=1;
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);
}
//cout<<"cnt["<<mask<<"]="<<cnt[mask]<<endl;
}
ans[0]=1;
for(int mask=1;mask<(1<<n);mask++)
{
int s=mask;
vector<int> S;
while(s>0)
{
S.PB(s);
s=(s-1)&mask;
}
while(!S.empty())
{
s=S.back();
S.pop_back();
if(isEdge[s])
continue;
//cout<<"cnt["<<(mask^s)<<"]="<<cnt[mask^s]<<endl;
//cout<<"!ns["<<(mask^s)<<"]="<<ans[mask^s]<<endl;
if(cnt[s]%2==1)
ans[mask]+=ans[mask^s];
else
ans[mask]+=mod-ans[mask^s];
ans[mask]%=mod;
}
//cout<<"ans["<<mask<<"]="<<ans[mask]<<endl;
}
LL answ=ans[(1<<n)-1];
answ*=(LL)m;
answ%=mod;
answ*=binpow(2,mod-2);
answ%=mod;
cout<<answ<<endl;
return 0;
}
/*
3 1
1 2
*/
Compilation message
amusementpark.cpp: In function 'int main()':
amusementpark.cpp:67:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<g[i].size();j++)
~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
380 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
380 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
6 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
5 ms |
376 KB |
Output is correct |
19 |
Correct |
5 ms |
376 KB |
Output is correct |
20 |
Correct |
5 ms |
376 KB |
Output is correct |
21 |
Correct |
5 ms |
376 KB |
Output is correct |
22 |
Correct |
5 ms |
380 KB |
Output is correct |
23 |
Correct |
5 ms |
376 KB |
Output is correct |
24 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
380 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
6 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
5 ms |
376 KB |
Output is correct |
19 |
Correct |
5 ms |
376 KB |
Output is correct |
20 |
Correct |
5 ms |
376 KB |
Output is correct |
21 |
Correct |
5 ms |
376 KB |
Output is correct |
22 |
Correct |
5 ms |
380 KB |
Output is correct |
23 |
Correct |
5 ms |
376 KB |
Output is correct |
24 |
Correct |
5 ms |
376 KB |
Output is correct |
25 |
Correct |
5 ms |
376 KB |
Output is correct |
26 |
Correct |
5 ms |
376 KB |
Output is correct |
27 |
Correct |
5 ms |
376 KB |
Output is correct |
28 |
Correct |
5 ms |
376 KB |
Output is correct |
29 |
Correct |
5 ms |
376 KB |
Output is correct |
30 |
Correct |
5 ms |
376 KB |
Output is correct |
31 |
Correct |
5 ms |
376 KB |
Output is correct |
32 |
Correct |
5 ms |
376 KB |
Output is correct |
33 |
Correct |
5 ms |
376 KB |
Output is correct |
34 |
Correct |
5 ms |
376 KB |
Output is correct |
35 |
Correct |
5 ms |
376 KB |
Output is correct |
36 |
Correct |
5 ms |
376 KB |
Output is correct |
37 |
Correct |
5 ms |
376 KB |
Output is correct |
38 |
Correct |
5 ms |
376 KB |
Output is correct |
39 |
Correct |
5 ms |
376 KB |
Output is correct |
40 |
Correct |
5 ms |
372 KB |
Output is correct |
41 |
Correct |
5 ms |
376 KB |
Output is correct |
42 |
Correct |
5 ms |
376 KB |
Output is correct |
43 |
Correct |
5 ms |
380 KB |
Output is correct |
44 |
Correct |
5 ms |
376 KB |
Output is correct |
45 |
Correct |
5 ms |
376 KB |
Output is correct |
46 |
Correct |
5 ms |
376 KB |
Output is correct |
47 |
Correct |
5 ms |
376 KB |
Output is correct |
48 |
Correct |
5 ms |
376 KB |
Output is correct |
49 |
Correct |
5 ms |
376 KB |
Output is correct |
50 |
Correct |
5 ms |
376 KB |
Output is correct |
51 |
Correct |
6 ms |
504 KB |
Output is correct |
52 |
Correct |
6 ms |
376 KB |
Output is correct |
53 |
Correct |
6 ms |
376 KB |
Output is correct |
54 |
Correct |
6 ms |
376 KB |
Output is correct |
55 |
Correct |
7 ms |
376 KB |
Output is correct |
56 |
Correct |
5 ms |
376 KB |
Output is correct |
57 |
Correct |
6 ms |
376 KB |
Output is correct |
58 |
Correct |
5 ms |
376 KB |
Output is correct |
59 |
Correct |
6 ms |
376 KB |
Output is correct |
60 |
Correct |
6 ms |
380 KB |
Output is correct |
61 |
Correct |
6 ms |
376 KB |
Output is correct |
62 |
Correct |
5 ms |
376 KB |
Output is correct |
63 |
Correct |
6 ms |
380 KB |
Output is correct |
64 |
Correct |
6 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
380 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
6 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
5 ms |
376 KB |
Output is correct |
19 |
Correct |
5 ms |
376 KB |
Output is correct |
20 |
Correct |
5 ms |
376 KB |
Output is correct |
21 |
Correct |
5 ms |
376 KB |
Output is correct |
22 |
Correct |
5 ms |
380 KB |
Output is correct |
23 |
Correct |
5 ms |
376 KB |
Output is correct |
24 |
Correct |
5 ms |
376 KB |
Output is correct |
25 |
Correct |
5 ms |
376 KB |
Output is correct |
26 |
Correct |
5 ms |
376 KB |
Output is correct |
27 |
Correct |
5 ms |
376 KB |
Output is correct |
28 |
Correct |
5 ms |
376 KB |
Output is correct |
29 |
Correct |
5 ms |
376 KB |
Output is correct |
30 |
Correct |
5 ms |
376 KB |
Output is correct |
31 |
Correct |
5 ms |
376 KB |
Output is correct |
32 |
Correct |
5 ms |
376 KB |
Output is correct |
33 |
Correct |
5 ms |
376 KB |
Output is correct |
34 |
Correct |
5 ms |
376 KB |
Output is correct |
35 |
Correct |
5 ms |
376 KB |
Output is correct |
36 |
Correct |
5 ms |
376 KB |
Output is correct |
37 |
Correct |
5 ms |
376 KB |
Output is correct |
38 |
Correct |
5 ms |
376 KB |
Output is correct |
39 |
Correct |
5 ms |
376 KB |
Output is correct |
40 |
Correct |
5 ms |
372 KB |
Output is correct |
41 |
Correct |
5 ms |
376 KB |
Output is correct |
42 |
Correct |
5 ms |
376 KB |
Output is correct |
43 |
Correct |
5 ms |
380 KB |
Output is correct |
44 |
Correct |
5 ms |
376 KB |
Output is correct |
45 |
Correct |
5 ms |
376 KB |
Output is correct |
46 |
Correct |
5 ms |
376 KB |
Output is correct |
47 |
Correct |
5 ms |
376 KB |
Output is correct |
48 |
Correct |
5 ms |
376 KB |
Output is correct |
49 |
Correct |
5 ms |
376 KB |
Output is correct |
50 |
Correct |
5 ms |
376 KB |
Output is correct |
51 |
Correct |
6 ms |
504 KB |
Output is correct |
52 |
Correct |
6 ms |
376 KB |
Output is correct |
53 |
Correct |
6 ms |
376 KB |
Output is correct |
54 |
Correct |
6 ms |
376 KB |
Output is correct |
55 |
Correct |
7 ms |
376 KB |
Output is correct |
56 |
Correct |
5 ms |
376 KB |
Output is correct |
57 |
Correct |
6 ms |
376 KB |
Output is correct |
58 |
Correct |
5 ms |
376 KB |
Output is correct |
59 |
Correct |
6 ms |
376 KB |
Output is correct |
60 |
Correct |
6 ms |
380 KB |
Output is correct |
61 |
Correct |
6 ms |
376 KB |
Output is correct |
62 |
Correct |
5 ms |
376 KB |
Output is correct |
63 |
Correct |
6 ms |
380 KB |
Output is correct |
64 |
Correct |
6 ms |
376 KB |
Output is correct |
65 |
Correct |
44 ms |
632 KB |
Output is correct |
66 |
Correct |
48 ms |
632 KB |
Output is correct |
67 |
Correct |
42 ms |
568 KB |
Output is correct |
68 |
Correct |
41 ms |
632 KB |
Output is correct |
69 |
Correct |
58 ms |
632 KB |
Output is correct |
70 |
Correct |
50 ms |
632 KB |
Output is correct |
71 |
Correct |
50 ms |
632 KB |
Output is correct |
72 |
Correct |
52 ms |
632 KB |
Output is correct |
73 |
Correct |
46 ms |
632 KB |
Output is correct |
74 |
Correct |
45 ms |
632 KB |
Output is correct |
75 |
Correct |
47 ms |
632 KB |
Output is correct |
76 |
Correct |
48 ms |
632 KB |
Output is correct |
77 |
Correct |
120 ms |
888 KB |
Output is correct |
78 |
Correct |
114 ms |
940 KB |
Output is correct |
79 |
Correct |
109 ms |
888 KB |
Output is correct |
80 |
Correct |
105 ms |
888 KB |
Output is correct |
81 |
Correct |
104 ms |
888 KB |
Output is correct |
82 |
Correct |
104 ms |
1016 KB |
Output is correct |
83 |
Correct |
99 ms |
888 KB |
Output is correct |
84 |
Correct |
100 ms |
888 KB |
Output is correct |
85 |
Correct |
158 ms |
888 KB |
Output is correct |
86 |
Correct |
133 ms |
1020 KB |
Output is correct |
87 |
Correct |
132 ms |
888 KB |
Output is correct |
88 |
Correct |
138 ms |
1028 KB |
Output is correct |
89 |
Correct |
118 ms |
848 KB |
Output is correct |
90 |
Correct |
122 ms |
892 KB |
Output is correct |
91 |
Correct |
122 ms |
888 KB |
Output is correct |
92 |
Correct |
123 ms |
888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
380 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
6 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
5 ms |
376 KB |
Output is correct |
19 |
Correct |
5 ms |
376 KB |
Output is correct |
20 |
Correct |
5 ms |
376 KB |
Output is correct |
21 |
Correct |
5 ms |
376 KB |
Output is correct |
22 |
Correct |
5 ms |
380 KB |
Output is correct |
23 |
Correct |
5 ms |
376 KB |
Output is correct |
24 |
Correct |
5 ms |
376 KB |
Output is correct |
25 |
Correct |
5 ms |
376 KB |
Output is correct |
26 |
Correct |
5 ms |
376 KB |
Output is correct |
27 |
Correct |
5 ms |
376 KB |
Output is correct |
28 |
Correct |
5 ms |
376 KB |
Output is correct |
29 |
Correct |
5 ms |
376 KB |
Output is correct |
30 |
Correct |
5 ms |
376 KB |
Output is correct |
31 |
Correct |
5 ms |
376 KB |
Output is correct |
32 |
Correct |
5 ms |
376 KB |
Output is correct |
33 |
Correct |
5 ms |
376 KB |
Output is correct |
34 |
Correct |
5 ms |
376 KB |
Output is correct |
35 |
Correct |
5 ms |
376 KB |
Output is correct |
36 |
Correct |
5 ms |
376 KB |
Output is correct |
37 |
Correct |
5 ms |
376 KB |
Output is correct |
38 |
Correct |
5 ms |
376 KB |
Output is correct |
39 |
Correct |
5 ms |
376 KB |
Output is correct |
40 |
Correct |
5 ms |
372 KB |
Output is correct |
41 |
Correct |
5 ms |
376 KB |
Output is correct |
42 |
Correct |
5 ms |
376 KB |
Output is correct |
43 |
Correct |
5 ms |
380 KB |
Output is correct |
44 |
Correct |
5 ms |
376 KB |
Output is correct |
45 |
Correct |
5 ms |
376 KB |
Output is correct |
46 |
Correct |
5 ms |
376 KB |
Output is correct |
47 |
Correct |
5 ms |
376 KB |
Output is correct |
48 |
Correct |
5 ms |
376 KB |
Output is correct |
49 |
Correct |
5 ms |
376 KB |
Output is correct |
50 |
Correct |
5 ms |
376 KB |
Output is correct |
51 |
Correct |
6 ms |
504 KB |
Output is correct |
52 |
Correct |
6 ms |
376 KB |
Output is correct |
53 |
Correct |
6 ms |
376 KB |
Output is correct |
54 |
Correct |
6 ms |
376 KB |
Output is correct |
55 |
Correct |
7 ms |
376 KB |
Output is correct |
56 |
Correct |
5 ms |
376 KB |
Output is correct |
57 |
Correct |
6 ms |
376 KB |
Output is correct |
58 |
Correct |
5 ms |
376 KB |
Output is correct |
59 |
Correct |
6 ms |
376 KB |
Output is correct |
60 |
Correct |
6 ms |
380 KB |
Output is correct |
61 |
Correct |
6 ms |
376 KB |
Output is correct |
62 |
Correct |
5 ms |
376 KB |
Output is correct |
63 |
Correct |
6 ms |
380 KB |
Output is correct |
64 |
Correct |
6 ms |
376 KB |
Output is correct |
65 |
Correct |
44 ms |
632 KB |
Output is correct |
66 |
Correct |
48 ms |
632 KB |
Output is correct |
67 |
Correct |
42 ms |
568 KB |
Output is correct |
68 |
Correct |
41 ms |
632 KB |
Output is correct |
69 |
Correct |
58 ms |
632 KB |
Output is correct |
70 |
Correct |
50 ms |
632 KB |
Output is correct |
71 |
Correct |
50 ms |
632 KB |
Output is correct |
72 |
Correct |
52 ms |
632 KB |
Output is correct |
73 |
Correct |
46 ms |
632 KB |
Output is correct |
74 |
Correct |
45 ms |
632 KB |
Output is correct |
75 |
Correct |
47 ms |
632 KB |
Output is correct |
76 |
Correct |
48 ms |
632 KB |
Output is correct |
77 |
Correct |
120 ms |
888 KB |
Output is correct |
78 |
Correct |
114 ms |
940 KB |
Output is correct |
79 |
Correct |
109 ms |
888 KB |
Output is correct |
80 |
Correct |
105 ms |
888 KB |
Output is correct |
81 |
Correct |
104 ms |
888 KB |
Output is correct |
82 |
Correct |
104 ms |
1016 KB |
Output is correct |
83 |
Correct |
99 ms |
888 KB |
Output is correct |
84 |
Correct |
100 ms |
888 KB |
Output is correct |
85 |
Correct |
158 ms |
888 KB |
Output is correct |
86 |
Correct |
133 ms |
1020 KB |
Output is correct |
87 |
Correct |
132 ms |
888 KB |
Output is correct |
88 |
Correct |
138 ms |
1028 KB |
Output is correct |
89 |
Correct |
118 ms |
848 KB |
Output is correct |
90 |
Correct |
122 ms |
892 KB |
Output is correct |
91 |
Correct |
122 ms |
888 KB |
Output is correct |
92 |
Correct |
123 ms |
888 KB |
Output is correct |
93 |
Execution timed out |
3055 ms |
4284 KB |
Time limit exceeded |
94 |
Halted |
0 ms |
0 KB |
- |