#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod=998244353;
ll n,i,j,a[1100][1100],k,l,r,x,y,z,w,s,t,m,b[1100000],bc[1100000],dp[1100000],c[1100000],ans;
vector<ll> v[1100000],u;
vector<ll> f(ll x)
{
vector<ll> v,u;
ll i,y=x,z=1,j;
for(i=1;i<=n;i++)
{
if(y&1)
{
v.push_back(1<<(i-1));
}
y>>=1;
}
u.push_back(0);
for(i=0;i<v.size();i++)
{
z=u.size();
for(j=0;j<z;j++)
{
u.push_back(u[j]+v[i]);
}
}
return u;
}
int main()
{
scanf("%lld %lld",&n,&m);
for(i=1;i<=m;i++)
{
scanf("%lld %lld",&x,&y);
a[x][y]=1;
a[y][x]=1;
}
t=1;
for(i=1;i<=n;i++)
{
t*=2;
}
for(i=0;i<t;i++)
{
x=i;
s=0;
for(j=1;j<=n;j++)
{
b[j]=x&1;
s+=x&1;
x>>=1;
}
bc[i]=s;
v[s].push_back(i);
c[i]=1;
for(j=1;j<=n;j++)
{
for(k=j+1;k<=n;k++)
{
if(b[j]==1&&b[k]==1&&a[j][k]==1)
c[i]=0;
}
}
}
dp[0]=1;
for(l=1;l<=n;l++)
{
for(j=0;j<v[l].size();j++)
{
x=v[l][j];
// printf("%lld ",x);
u=f(x);
for(i=0;i<u.size();i++)
{
// printf("[%lld,%lld]",u[i],c[u[i]]*dp[x-u[i]]);
if(u[i]==0)
continue;
if(bc[u[i]]&1)
{
dp[x]+=c[u[i]]*dp[x-u[i]];
}
else
dp[x]-=c[u[i]]*dp[x-u[i]];
dp[x]=(dp[x]%mod+mod)%mod;
}
// printf("(%lld) ",dp[x]);
}
// printf("\n");
}
ans=dp[t-1]*(mod+1)/2%mod*m%mod;
printf("%lld",ans);
}
Compilation message
amusementpark.cpp: In function 'std::vector<long long int> f(ll)':
amusementpark.cpp:20:14: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | for(i=0;i<v.size();i++)
| ~^~~~~~~~~
amusementpark.cpp: In function 'int main()':
amusementpark.cpp:69:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
69 | for(j=0;j<v[l].size();j++)
| ~^~~~~~~~~~~~
amusementpark.cpp:74:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
74 | for(i=0;i<u.size();i++)
| ~^~~~~~~~~
amusementpark.cpp:83:17: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
83 | else
| ^~~~
amusementpark.cpp:85:21: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
85 | dp[x]=(dp[x]%mod+mod)%mod;
| ^~
amusementpark.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
32 | scanf("%lld %lld",&n,&m);
| ~~~~~^~~~~~~~~~~~~~~~~~~
amusementpark.cpp:35:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
35 | scanf("%lld %lld",&x,&y);
| ~~~~~^~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
35416 KB |
Output is correct |
2 |
Correct |
7 ms |
35572 KB |
Output is correct |
3 |
Correct |
10 ms |
35420 KB |
Output is correct |
4 |
Correct |
11 ms |
35420 KB |
Output is correct |
5 |
Correct |
10 ms |
35500 KB |
Output is correct |
6 |
Correct |
10 ms |
35420 KB |
Output is correct |
7 |
Correct |
11 ms |
35420 KB |
Output is correct |
8 |
Correct |
10 ms |
35420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
35416 KB |
Output is correct |
2 |
Correct |
7 ms |
35572 KB |
Output is correct |
3 |
Correct |
10 ms |
35420 KB |
Output is correct |
4 |
Correct |
11 ms |
35420 KB |
Output is correct |
5 |
Correct |
10 ms |
35500 KB |
Output is correct |
6 |
Correct |
10 ms |
35420 KB |
Output is correct |
7 |
Correct |
11 ms |
35420 KB |
Output is correct |
8 |
Correct |
10 ms |
35420 KB |
Output is correct |
9 |
Correct |
11 ms |
35448 KB |
Output is correct |
10 |
Correct |
10 ms |
35420 KB |
Output is correct |
11 |
Correct |
10 ms |
35420 KB |
Output is correct |
12 |
Correct |
9 ms |
35420 KB |
Output is correct |
13 |
Correct |
11 ms |
35420 KB |
Output is correct |
14 |
Correct |
10 ms |
35420 KB |
Output is correct |
15 |
Correct |
10 ms |
35576 KB |
Output is correct |
16 |
Correct |
12 ms |
35416 KB |
Output is correct |
17 |
Correct |
11 ms |
35416 KB |
Output is correct |
18 |
Correct |
10 ms |
35420 KB |
Output is correct |
19 |
Correct |
11 ms |
35420 KB |
Output is correct |
20 |
Correct |
9 ms |
35420 KB |
Output is correct |
21 |
Correct |
10 ms |
35508 KB |
Output is correct |
22 |
Correct |
9 ms |
35420 KB |
Output is correct |
23 |
Correct |
10 ms |
35420 KB |
Output is correct |
24 |
Correct |
9 ms |
35416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
35416 KB |
Output is correct |
2 |
Correct |
7 ms |
35572 KB |
Output is correct |
3 |
Correct |
10 ms |
35420 KB |
Output is correct |
4 |
Correct |
11 ms |
35420 KB |
Output is correct |
5 |
Correct |
10 ms |
35500 KB |
Output is correct |
6 |
Correct |
10 ms |
35420 KB |
Output is correct |
7 |
Correct |
11 ms |
35420 KB |
Output is correct |
8 |
Correct |
10 ms |
35420 KB |
Output is correct |
9 |
Correct |
11 ms |
35448 KB |
Output is correct |
10 |
Correct |
10 ms |
35420 KB |
Output is correct |
11 |
Correct |
10 ms |
35420 KB |
Output is correct |
12 |
Correct |
9 ms |
35420 KB |
Output is correct |
13 |
Correct |
11 ms |
35420 KB |
Output is correct |
14 |
Correct |
10 ms |
35420 KB |
Output is correct |
15 |
Correct |
10 ms |
35576 KB |
Output is correct |
16 |
Correct |
12 ms |
35416 KB |
Output is correct |
17 |
Correct |
11 ms |
35416 KB |
Output is correct |
18 |
Correct |
10 ms |
35420 KB |
Output is correct |
19 |
Correct |
11 ms |
35420 KB |
Output is correct |
20 |
Correct |
9 ms |
35420 KB |
Output is correct |
21 |
Correct |
10 ms |
35508 KB |
Output is correct |
22 |
Correct |
9 ms |
35420 KB |
Output is correct |
23 |
Correct |
10 ms |
35420 KB |
Output is correct |
24 |
Correct |
9 ms |
35416 KB |
Output is correct |
25 |
Correct |
10 ms |
35416 KB |
Output is correct |
26 |
Correct |
10 ms |
35436 KB |
Output is correct |
27 |
Correct |
11 ms |
35732 KB |
Output is correct |
28 |
Correct |
11 ms |
35420 KB |
Output is correct |
29 |
Correct |
11 ms |
35420 KB |
Output is correct |
30 |
Correct |
11 ms |
35416 KB |
Output is correct |
31 |
Correct |
11 ms |
35416 KB |
Output is correct |
32 |
Correct |
11 ms |
35416 KB |
Output is correct |
33 |
Correct |
11 ms |
35420 KB |
Output is correct |
34 |
Correct |
10 ms |
35420 KB |
Output is correct |
35 |
Correct |
10 ms |
35420 KB |
Output is correct |
36 |
Correct |
10 ms |
35420 KB |
Output is correct |
37 |
Correct |
11 ms |
35416 KB |
Output is correct |
38 |
Correct |
10 ms |
35416 KB |
Output is correct |
39 |
Correct |
10 ms |
35420 KB |
Output is correct |
40 |
Correct |
10 ms |
35420 KB |
Output is correct |
41 |
Correct |
10 ms |
35416 KB |
Output is correct |
42 |
Correct |
11 ms |
35420 KB |
Output is correct |
43 |
Correct |
10 ms |
35416 KB |
Output is correct |
44 |
Correct |
12 ms |
35416 KB |
Output is correct |
45 |
Correct |
11 ms |
35524 KB |
Output is correct |
46 |
Correct |
11 ms |
35416 KB |
Output is correct |
47 |
Correct |
10 ms |
35420 KB |
Output is correct |
48 |
Correct |
10 ms |
35420 KB |
Output is correct |
49 |
Correct |
10 ms |
35416 KB |
Output is correct |
50 |
Correct |
11 ms |
35420 KB |
Output is correct |
51 |
Correct |
10 ms |
35420 KB |
Output is correct |
52 |
Correct |
11 ms |
35416 KB |
Output is correct |
53 |
Correct |
11 ms |
35416 KB |
Output is correct |
54 |
Correct |
12 ms |
35420 KB |
Output is correct |
55 |
Correct |
11 ms |
35420 KB |
Output is correct |
56 |
Correct |
11 ms |
35420 KB |
Output is correct |
57 |
Correct |
12 ms |
35416 KB |
Output is correct |
58 |
Correct |
11 ms |
35520 KB |
Output is correct |
59 |
Correct |
12 ms |
35420 KB |
Output is correct |
60 |
Correct |
10 ms |
35420 KB |
Output is correct |
61 |
Correct |
11 ms |
35420 KB |
Output is correct |
62 |
Correct |
11 ms |
35440 KB |
Output is correct |
63 |
Correct |
11 ms |
35444 KB |
Output is correct |
64 |
Correct |
11 ms |
35416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
35416 KB |
Output is correct |
2 |
Correct |
7 ms |
35572 KB |
Output is correct |
3 |
Correct |
10 ms |
35420 KB |
Output is correct |
4 |
Correct |
11 ms |
35420 KB |
Output is correct |
5 |
Correct |
10 ms |
35500 KB |
Output is correct |
6 |
Correct |
10 ms |
35420 KB |
Output is correct |
7 |
Correct |
11 ms |
35420 KB |
Output is correct |
8 |
Correct |
10 ms |
35420 KB |
Output is correct |
9 |
Correct |
11 ms |
35448 KB |
Output is correct |
10 |
Correct |
10 ms |
35420 KB |
Output is correct |
11 |
Correct |
10 ms |
35420 KB |
Output is correct |
12 |
Correct |
9 ms |
35420 KB |
Output is correct |
13 |
Correct |
11 ms |
35420 KB |
Output is correct |
14 |
Correct |
10 ms |
35420 KB |
Output is correct |
15 |
Correct |
10 ms |
35576 KB |
Output is correct |
16 |
Correct |
12 ms |
35416 KB |
Output is correct |
17 |
Correct |
11 ms |
35416 KB |
Output is correct |
18 |
Correct |
10 ms |
35420 KB |
Output is correct |
19 |
Correct |
11 ms |
35420 KB |
Output is correct |
20 |
Correct |
9 ms |
35420 KB |
Output is correct |
21 |
Correct |
10 ms |
35508 KB |
Output is correct |
22 |
Correct |
9 ms |
35420 KB |
Output is correct |
23 |
Correct |
10 ms |
35420 KB |
Output is correct |
24 |
Correct |
9 ms |
35416 KB |
Output is correct |
25 |
Correct |
10 ms |
35416 KB |
Output is correct |
26 |
Correct |
10 ms |
35436 KB |
Output is correct |
27 |
Correct |
11 ms |
35732 KB |
Output is correct |
28 |
Correct |
11 ms |
35420 KB |
Output is correct |
29 |
Correct |
11 ms |
35420 KB |
Output is correct |
30 |
Correct |
11 ms |
35416 KB |
Output is correct |
31 |
Correct |
11 ms |
35416 KB |
Output is correct |
32 |
Correct |
11 ms |
35416 KB |
Output is correct |
33 |
Correct |
11 ms |
35420 KB |
Output is correct |
34 |
Correct |
10 ms |
35420 KB |
Output is correct |
35 |
Correct |
10 ms |
35420 KB |
Output is correct |
36 |
Correct |
10 ms |
35420 KB |
Output is correct |
37 |
Correct |
11 ms |
35416 KB |
Output is correct |
38 |
Correct |
10 ms |
35416 KB |
Output is correct |
39 |
Correct |
10 ms |
35420 KB |
Output is correct |
40 |
Correct |
10 ms |
35420 KB |
Output is correct |
41 |
Correct |
10 ms |
35416 KB |
Output is correct |
42 |
Correct |
11 ms |
35420 KB |
Output is correct |
43 |
Correct |
10 ms |
35416 KB |
Output is correct |
44 |
Correct |
12 ms |
35416 KB |
Output is correct |
45 |
Correct |
11 ms |
35524 KB |
Output is correct |
46 |
Correct |
11 ms |
35416 KB |
Output is correct |
47 |
Correct |
10 ms |
35420 KB |
Output is correct |
48 |
Correct |
10 ms |
35420 KB |
Output is correct |
49 |
Correct |
10 ms |
35416 KB |
Output is correct |
50 |
Correct |
11 ms |
35420 KB |
Output is correct |
51 |
Correct |
10 ms |
35420 KB |
Output is correct |
52 |
Correct |
11 ms |
35416 KB |
Output is correct |
53 |
Correct |
11 ms |
35416 KB |
Output is correct |
54 |
Correct |
12 ms |
35420 KB |
Output is correct |
55 |
Correct |
11 ms |
35420 KB |
Output is correct |
56 |
Correct |
11 ms |
35420 KB |
Output is correct |
57 |
Correct |
12 ms |
35416 KB |
Output is correct |
58 |
Correct |
11 ms |
35520 KB |
Output is correct |
59 |
Correct |
12 ms |
35420 KB |
Output is correct |
60 |
Correct |
10 ms |
35420 KB |
Output is correct |
61 |
Correct |
11 ms |
35420 KB |
Output is correct |
62 |
Correct |
11 ms |
35440 KB |
Output is correct |
63 |
Correct |
11 ms |
35444 KB |
Output is correct |
64 |
Correct |
11 ms |
35416 KB |
Output is correct |
65 |
Correct |
58 ms |
35920 KB |
Output is correct |
66 |
Correct |
58 ms |
35924 KB |
Output is correct |
67 |
Correct |
60 ms |
35924 KB |
Output is correct |
68 |
Correct |
59 ms |
35924 KB |
Output is correct |
69 |
Correct |
59 ms |
35920 KB |
Output is correct |
70 |
Correct |
62 ms |
35920 KB |
Output is correct |
71 |
Correct |
59 ms |
35924 KB |
Output is correct |
72 |
Correct |
60 ms |
35924 KB |
Output is correct |
73 |
Correct |
59 ms |
35920 KB |
Output is correct |
74 |
Correct |
60 ms |
35960 KB |
Output is correct |
75 |
Correct |
59 ms |
35932 KB |
Output is correct |
76 |
Correct |
58 ms |
35920 KB |
Output is correct |
77 |
Correct |
155 ms |
38360 KB |
Output is correct |
78 |
Correct |
153 ms |
38484 KB |
Output is correct |
79 |
Correct |
148 ms |
38408 KB |
Output is correct |
80 |
Correct |
148 ms |
38448 KB |
Output is correct |
81 |
Correct |
151 ms |
38320 KB |
Output is correct |
82 |
Correct |
148 ms |
38444 KB |
Output is correct |
83 |
Correct |
148 ms |
38404 KB |
Output is correct |
84 |
Correct |
148 ms |
38436 KB |
Output is correct |
85 |
Correct |
156 ms |
38516 KB |
Output is correct |
86 |
Correct |
148 ms |
38444 KB |
Output is correct |
87 |
Correct |
148 ms |
38440 KB |
Output is correct |
88 |
Correct |
150 ms |
38444 KB |
Output is correct |
89 |
Correct |
149 ms |
38416 KB |
Output is correct |
90 |
Correct |
151 ms |
38444 KB |
Output is correct |
91 |
Correct |
147 ms |
38440 KB |
Output is correct |
92 |
Correct |
150 ms |
38436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
35416 KB |
Output is correct |
2 |
Correct |
7 ms |
35572 KB |
Output is correct |
3 |
Correct |
10 ms |
35420 KB |
Output is correct |
4 |
Correct |
11 ms |
35420 KB |
Output is correct |
5 |
Correct |
10 ms |
35500 KB |
Output is correct |
6 |
Correct |
10 ms |
35420 KB |
Output is correct |
7 |
Correct |
11 ms |
35420 KB |
Output is correct |
8 |
Correct |
10 ms |
35420 KB |
Output is correct |
9 |
Correct |
11 ms |
35448 KB |
Output is correct |
10 |
Correct |
10 ms |
35420 KB |
Output is correct |
11 |
Correct |
10 ms |
35420 KB |
Output is correct |
12 |
Correct |
9 ms |
35420 KB |
Output is correct |
13 |
Correct |
11 ms |
35420 KB |
Output is correct |
14 |
Correct |
10 ms |
35420 KB |
Output is correct |
15 |
Correct |
10 ms |
35576 KB |
Output is correct |
16 |
Correct |
12 ms |
35416 KB |
Output is correct |
17 |
Correct |
11 ms |
35416 KB |
Output is correct |
18 |
Correct |
10 ms |
35420 KB |
Output is correct |
19 |
Correct |
11 ms |
35420 KB |
Output is correct |
20 |
Correct |
9 ms |
35420 KB |
Output is correct |
21 |
Correct |
10 ms |
35508 KB |
Output is correct |
22 |
Correct |
9 ms |
35420 KB |
Output is correct |
23 |
Correct |
10 ms |
35420 KB |
Output is correct |
24 |
Correct |
9 ms |
35416 KB |
Output is correct |
25 |
Correct |
10 ms |
35416 KB |
Output is correct |
26 |
Correct |
10 ms |
35436 KB |
Output is correct |
27 |
Correct |
11 ms |
35732 KB |
Output is correct |
28 |
Correct |
11 ms |
35420 KB |
Output is correct |
29 |
Correct |
11 ms |
35420 KB |
Output is correct |
30 |
Correct |
11 ms |
35416 KB |
Output is correct |
31 |
Correct |
11 ms |
35416 KB |
Output is correct |
32 |
Correct |
11 ms |
35416 KB |
Output is correct |
33 |
Correct |
11 ms |
35420 KB |
Output is correct |
34 |
Correct |
10 ms |
35420 KB |
Output is correct |
35 |
Correct |
10 ms |
35420 KB |
Output is correct |
36 |
Correct |
10 ms |
35420 KB |
Output is correct |
37 |
Correct |
11 ms |
35416 KB |
Output is correct |
38 |
Correct |
10 ms |
35416 KB |
Output is correct |
39 |
Correct |
10 ms |
35420 KB |
Output is correct |
40 |
Correct |
10 ms |
35420 KB |
Output is correct |
41 |
Correct |
10 ms |
35416 KB |
Output is correct |
42 |
Correct |
11 ms |
35420 KB |
Output is correct |
43 |
Correct |
10 ms |
35416 KB |
Output is correct |
44 |
Correct |
12 ms |
35416 KB |
Output is correct |
45 |
Correct |
11 ms |
35524 KB |
Output is correct |
46 |
Correct |
11 ms |
35416 KB |
Output is correct |
47 |
Correct |
10 ms |
35420 KB |
Output is correct |
48 |
Correct |
10 ms |
35420 KB |
Output is correct |
49 |
Correct |
10 ms |
35416 KB |
Output is correct |
50 |
Correct |
11 ms |
35420 KB |
Output is correct |
51 |
Correct |
10 ms |
35420 KB |
Output is correct |
52 |
Correct |
11 ms |
35416 KB |
Output is correct |
53 |
Correct |
11 ms |
35416 KB |
Output is correct |
54 |
Correct |
12 ms |
35420 KB |
Output is correct |
55 |
Correct |
11 ms |
35420 KB |
Output is correct |
56 |
Correct |
11 ms |
35420 KB |
Output is correct |
57 |
Correct |
12 ms |
35416 KB |
Output is correct |
58 |
Correct |
11 ms |
35520 KB |
Output is correct |
59 |
Correct |
12 ms |
35420 KB |
Output is correct |
60 |
Correct |
10 ms |
35420 KB |
Output is correct |
61 |
Correct |
11 ms |
35420 KB |
Output is correct |
62 |
Correct |
11 ms |
35440 KB |
Output is correct |
63 |
Correct |
11 ms |
35444 KB |
Output is correct |
64 |
Correct |
11 ms |
35416 KB |
Output is correct |
65 |
Correct |
58 ms |
35920 KB |
Output is correct |
66 |
Correct |
58 ms |
35924 KB |
Output is correct |
67 |
Correct |
60 ms |
35924 KB |
Output is correct |
68 |
Correct |
59 ms |
35924 KB |
Output is correct |
69 |
Correct |
59 ms |
35920 KB |
Output is correct |
70 |
Correct |
62 ms |
35920 KB |
Output is correct |
71 |
Correct |
59 ms |
35924 KB |
Output is correct |
72 |
Correct |
60 ms |
35924 KB |
Output is correct |
73 |
Correct |
59 ms |
35920 KB |
Output is correct |
74 |
Correct |
60 ms |
35960 KB |
Output is correct |
75 |
Correct |
59 ms |
35932 KB |
Output is correct |
76 |
Correct |
58 ms |
35920 KB |
Output is correct |
77 |
Correct |
155 ms |
38360 KB |
Output is correct |
78 |
Correct |
153 ms |
38484 KB |
Output is correct |
79 |
Correct |
148 ms |
38408 KB |
Output is correct |
80 |
Correct |
148 ms |
38448 KB |
Output is correct |
81 |
Correct |
151 ms |
38320 KB |
Output is correct |
82 |
Correct |
148 ms |
38444 KB |
Output is correct |
83 |
Correct |
148 ms |
38404 KB |
Output is correct |
84 |
Correct |
148 ms |
38436 KB |
Output is correct |
85 |
Correct |
156 ms |
38516 KB |
Output is correct |
86 |
Correct |
148 ms |
38444 KB |
Output is correct |
87 |
Correct |
148 ms |
38440 KB |
Output is correct |
88 |
Correct |
150 ms |
38444 KB |
Output is correct |
89 |
Correct |
149 ms |
38416 KB |
Output is correct |
90 |
Correct |
151 ms |
38444 KB |
Output is correct |
91 |
Correct |
147 ms |
38440 KB |
Output is correct |
92 |
Correct |
150 ms |
38436 KB |
Output is correct |
93 |
Execution timed out |
3090 ms |
43572 KB |
Time limit exceeded |
94 |
Halted |
0 ms |
0 KB |
- |