답안 #909328

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
909328 2024-01-17T07:11:12 Z ibm2006 Amusement Park (CEOI19_amusementpark) C++17
100 / 100
1566 ms 48692 KB
#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;
    c[0]=0;
    for(i=0;i<t;i++)
    {
        if(!(bc[i]&1))
            c[i]*=-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++)
            {
                    dp[x]+=c[u[i]]*dp[x-u[i]];
            }
           dp[x]=(dp[x]%mod+mod)%mod;
        }
      //  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:75: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]
   75 |         for(j=0;j<v[l].size();j++)
      |                 ~^~~~~~~~~~~~
amusementpark.cpp:80: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]
   80 |             for(i=0;i<u.size();i++)
      |                     ~^~~~~~~~~
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);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 35420 KB Output is correct
2 Correct 10 ms 35420 KB Output is correct
3 Correct 10 ms 35416 KB Output is correct
4 Correct 10 ms 35420 KB Output is correct
5 Correct 10 ms 35420 KB Output is correct
6 Correct 11 ms 35504 KB Output is correct
7 Correct 11 ms 35420 KB Output is correct
8 Correct 10 ms 35420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 35420 KB Output is correct
2 Correct 10 ms 35420 KB Output is correct
3 Correct 10 ms 35416 KB Output is correct
4 Correct 10 ms 35420 KB Output is correct
5 Correct 10 ms 35420 KB Output is correct
6 Correct 11 ms 35504 KB Output is correct
7 Correct 11 ms 35420 KB Output is correct
8 Correct 10 ms 35420 KB Output is correct
9 Correct 10 ms 35508 KB Output is correct
10 Correct 10 ms 35420 KB Output is correct
11 Correct 11 ms 35428 KB Output is correct
12 Correct 11 ms 35420 KB Output is correct
13 Correct 11 ms 35420 KB Output is correct
14 Correct 11 ms 35420 KB Output is correct
15 Correct 11 ms 35508 KB Output is correct
16 Correct 10 ms 35420 KB Output is correct
17 Correct 11 ms 35416 KB Output is correct
18 Correct 11 ms 35416 KB Output is correct
19 Correct 11 ms 35420 KB Output is correct
20 Correct 10 ms 35420 KB Output is correct
21 Correct 11 ms 35420 KB Output is correct
22 Correct 10 ms 35420 KB Output is correct
23 Correct 11 ms 35416 KB Output is correct
24 Correct 10 ms 35420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 35420 KB Output is correct
2 Correct 10 ms 35420 KB Output is correct
3 Correct 10 ms 35416 KB Output is correct
4 Correct 10 ms 35420 KB Output is correct
5 Correct 10 ms 35420 KB Output is correct
6 Correct 11 ms 35504 KB Output is correct
7 Correct 11 ms 35420 KB Output is correct
8 Correct 10 ms 35420 KB Output is correct
9 Correct 10 ms 35508 KB Output is correct
10 Correct 10 ms 35420 KB Output is correct
11 Correct 11 ms 35428 KB Output is correct
12 Correct 11 ms 35420 KB Output is correct
13 Correct 11 ms 35420 KB Output is correct
14 Correct 11 ms 35420 KB Output is correct
15 Correct 11 ms 35508 KB Output is correct
16 Correct 10 ms 35420 KB Output is correct
17 Correct 11 ms 35416 KB Output is correct
18 Correct 11 ms 35416 KB Output is correct
19 Correct 11 ms 35420 KB Output is correct
20 Correct 10 ms 35420 KB Output is correct
21 Correct 11 ms 35420 KB Output is correct
22 Correct 10 ms 35420 KB Output is correct
23 Correct 11 ms 35416 KB Output is correct
24 Correct 10 ms 35420 KB Output is correct
25 Correct 11 ms 35512 KB Output is correct
26 Correct 11 ms 35416 KB Output is correct
27 Correct 12 ms 35420 KB Output is correct
28 Correct 11 ms 35416 KB Output is correct
29 Correct 11 ms 35420 KB Output is correct
30 Correct 12 ms 35416 KB Output is correct
31 Correct 11 ms 35416 KB Output is correct
32 Correct 10 ms 35420 KB Output is correct
33 Correct 11 ms 35508 KB Output is correct
34 Correct 10 ms 35420 KB Output is correct
35 Correct 10 ms 35472 KB Output is correct
36 Correct 11 ms 35420 KB Output is correct
37 Correct 12 ms 35420 KB Output is correct
38 Correct 10 ms 35516 KB Output is correct
39 Correct 12 ms 35420 KB Output is correct
40 Correct 11 ms 35676 KB Output is correct
41 Correct 11 ms 35588 KB Output is correct
42 Correct 10 ms 35496 KB Output is correct
43 Correct 12 ms 35416 KB Output is correct
44 Correct 13 ms 35420 KB Output is correct
45 Correct 10 ms 35496 KB Output is correct
46 Correct 10 ms 35504 KB Output is correct
47 Correct 11 ms 35420 KB Output is correct
48 Correct 11 ms 35420 KB Output is correct
49 Correct 11 ms 35420 KB Output is correct
50 Correct 12 ms 35420 KB Output is correct
51 Correct 10 ms 35572 KB Output is correct
52 Correct 11 ms 35416 KB Output is correct
53 Correct 11 ms 35420 KB Output is correct
54 Correct 11 ms 35676 KB Output is correct
55 Correct 12 ms 35452 KB Output is correct
56 Correct 11 ms 35420 KB Output is correct
57 Correct 11 ms 35416 KB Output is correct
58 Correct 10 ms 35420 KB Output is correct
59 Correct 11 ms 35420 KB Output is correct
60 Correct 11 ms 35420 KB Output is correct
61 Correct 12 ms 35420 KB Output is correct
62 Correct 11 ms 35416 KB Output is correct
63 Correct 10 ms 35420 KB Output is correct
64 Correct 11 ms 35416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 35420 KB Output is correct
2 Correct 10 ms 35420 KB Output is correct
3 Correct 10 ms 35416 KB Output is correct
4 Correct 10 ms 35420 KB Output is correct
5 Correct 10 ms 35420 KB Output is correct
6 Correct 11 ms 35504 KB Output is correct
7 Correct 11 ms 35420 KB Output is correct
8 Correct 10 ms 35420 KB Output is correct
9 Correct 10 ms 35508 KB Output is correct
10 Correct 10 ms 35420 KB Output is correct
11 Correct 11 ms 35428 KB Output is correct
12 Correct 11 ms 35420 KB Output is correct
13 Correct 11 ms 35420 KB Output is correct
14 Correct 11 ms 35420 KB Output is correct
15 Correct 11 ms 35508 KB Output is correct
16 Correct 10 ms 35420 KB Output is correct
17 Correct 11 ms 35416 KB Output is correct
18 Correct 11 ms 35416 KB Output is correct
19 Correct 11 ms 35420 KB Output is correct
20 Correct 10 ms 35420 KB Output is correct
21 Correct 11 ms 35420 KB Output is correct
22 Correct 10 ms 35420 KB Output is correct
23 Correct 11 ms 35416 KB Output is correct
24 Correct 10 ms 35420 KB Output is correct
25 Correct 11 ms 35512 KB Output is correct
26 Correct 11 ms 35416 KB Output is correct
27 Correct 12 ms 35420 KB Output is correct
28 Correct 11 ms 35416 KB Output is correct
29 Correct 11 ms 35420 KB Output is correct
30 Correct 12 ms 35416 KB Output is correct
31 Correct 11 ms 35416 KB Output is correct
32 Correct 10 ms 35420 KB Output is correct
33 Correct 11 ms 35508 KB Output is correct
34 Correct 10 ms 35420 KB Output is correct
35 Correct 10 ms 35472 KB Output is correct
36 Correct 11 ms 35420 KB Output is correct
37 Correct 12 ms 35420 KB Output is correct
38 Correct 10 ms 35516 KB Output is correct
39 Correct 12 ms 35420 KB Output is correct
40 Correct 11 ms 35676 KB Output is correct
41 Correct 11 ms 35588 KB Output is correct
42 Correct 10 ms 35496 KB Output is correct
43 Correct 12 ms 35416 KB Output is correct
44 Correct 13 ms 35420 KB Output is correct
45 Correct 10 ms 35496 KB Output is correct
46 Correct 10 ms 35504 KB Output is correct
47 Correct 11 ms 35420 KB Output is correct
48 Correct 11 ms 35420 KB Output is correct
49 Correct 11 ms 35420 KB Output is correct
50 Correct 12 ms 35420 KB Output is correct
51 Correct 10 ms 35572 KB Output is correct
52 Correct 11 ms 35416 KB Output is correct
53 Correct 11 ms 35420 KB Output is correct
54 Correct 11 ms 35676 KB Output is correct
55 Correct 12 ms 35452 KB Output is correct
56 Correct 11 ms 35420 KB Output is correct
57 Correct 11 ms 35416 KB Output is correct
58 Correct 10 ms 35420 KB Output is correct
59 Correct 11 ms 35420 KB Output is correct
60 Correct 11 ms 35420 KB Output is correct
61 Correct 12 ms 35420 KB Output is correct
62 Correct 11 ms 35416 KB Output is correct
63 Correct 10 ms 35420 KB Output is correct
64 Correct 11 ms 35416 KB Output is correct
65 Correct 31 ms 35920 KB Output is correct
66 Correct 30 ms 35932 KB Output is correct
67 Correct 31 ms 35932 KB Output is correct
68 Correct 38 ms 36120 KB Output is correct
69 Correct 34 ms 35920 KB Output is correct
70 Correct 31 ms 35920 KB Output is correct
71 Correct 30 ms 35932 KB Output is correct
72 Correct 30 ms 35928 KB Output is correct
73 Correct 30 ms 35928 KB Output is correct
74 Correct 30 ms 35932 KB Output is correct
75 Correct 30 ms 35932 KB Output is correct
76 Correct 30 ms 35920 KB Output is correct
77 Correct 63 ms 38404 KB Output is correct
78 Correct 67 ms 38400 KB Output is correct
79 Correct 75 ms 38408 KB Output is correct
80 Correct 71 ms 38444 KB Output is correct
81 Correct 63 ms 38432 KB Output is correct
82 Correct 64 ms 38408 KB Output is correct
83 Correct 70 ms 38404 KB Output is correct
84 Correct 63 ms 38408 KB Output is correct
85 Correct 68 ms 38404 KB Output is correct
86 Correct 63 ms 38424 KB Output is correct
87 Correct 62 ms 38408 KB Output is correct
88 Correct 75 ms 38400 KB Output is correct
89 Correct 63 ms 38408 KB Output is correct
90 Correct 64 ms 38400 KB Output is correct
91 Correct 74 ms 38448 KB Output is correct
92 Correct 64 ms 38404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 35420 KB Output is correct
2 Correct 10 ms 35420 KB Output is correct
3 Correct 10 ms 35416 KB Output is correct
4 Correct 10 ms 35420 KB Output is correct
5 Correct 10 ms 35420 KB Output is correct
6 Correct 11 ms 35504 KB Output is correct
7 Correct 11 ms 35420 KB Output is correct
8 Correct 10 ms 35420 KB Output is correct
9 Correct 10 ms 35508 KB Output is correct
10 Correct 10 ms 35420 KB Output is correct
11 Correct 11 ms 35428 KB Output is correct
12 Correct 11 ms 35420 KB Output is correct
13 Correct 11 ms 35420 KB Output is correct
14 Correct 11 ms 35420 KB Output is correct
15 Correct 11 ms 35508 KB Output is correct
16 Correct 10 ms 35420 KB Output is correct
17 Correct 11 ms 35416 KB Output is correct
18 Correct 11 ms 35416 KB Output is correct
19 Correct 11 ms 35420 KB Output is correct
20 Correct 10 ms 35420 KB Output is correct
21 Correct 11 ms 35420 KB Output is correct
22 Correct 10 ms 35420 KB Output is correct
23 Correct 11 ms 35416 KB Output is correct
24 Correct 10 ms 35420 KB Output is correct
25 Correct 11 ms 35512 KB Output is correct
26 Correct 11 ms 35416 KB Output is correct
27 Correct 12 ms 35420 KB Output is correct
28 Correct 11 ms 35416 KB Output is correct
29 Correct 11 ms 35420 KB Output is correct
30 Correct 12 ms 35416 KB Output is correct
31 Correct 11 ms 35416 KB Output is correct
32 Correct 10 ms 35420 KB Output is correct
33 Correct 11 ms 35508 KB Output is correct
34 Correct 10 ms 35420 KB Output is correct
35 Correct 10 ms 35472 KB Output is correct
36 Correct 11 ms 35420 KB Output is correct
37 Correct 12 ms 35420 KB Output is correct
38 Correct 10 ms 35516 KB Output is correct
39 Correct 12 ms 35420 KB Output is correct
40 Correct 11 ms 35676 KB Output is correct
41 Correct 11 ms 35588 KB Output is correct
42 Correct 10 ms 35496 KB Output is correct
43 Correct 12 ms 35416 KB Output is correct
44 Correct 13 ms 35420 KB Output is correct
45 Correct 10 ms 35496 KB Output is correct
46 Correct 10 ms 35504 KB Output is correct
47 Correct 11 ms 35420 KB Output is correct
48 Correct 11 ms 35420 KB Output is correct
49 Correct 11 ms 35420 KB Output is correct
50 Correct 12 ms 35420 KB Output is correct
51 Correct 10 ms 35572 KB Output is correct
52 Correct 11 ms 35416 KB Output is correct
53 Correct 11 ms 35420 KB Output is correct
54 Correct 11 ms 35676 KB Output is correct
55 Correct 12 ms 35452 KB Output is correct
56 Correct 11 ms 35420 KB Output is correct
57 Correct 11 ms 35416 KB Output is correct
58 Correct 10 ms 35420 KB Output is correct
59 Correct 11 ms 35420 KB Output is correct
60 Correct 11 ms 35420 KB Output is correct
61 Correct 12 ms 35420 KB Output is correct
62 Correct 11 ms 35416 KB Output is correct
63 Correct 10 ms 35420 KB Output is correct
64 Correct 11 ms 35416 KB Output is correct
65 Correct 31 ms 35920 KB Output is correct
66 Correct 30 ms 35932 KB Output is correct
67 Correct 31 ms 35932 KB Output is correct
68 Correct 38 ms 36120 KB Output is correct
69 Correct 34 ms 35920 KB Output is correct
70 Correct 31 ms 35920 KB Output is correct
71 Correct 30 ms 35932 KB Output is correct
72 Correct 30 ms 35928 KB Output is correct
73 Correct 30 ms 35928 KB Output is correct
74 Correct 30 ms 35932 KB Output is correct
75 Correct 30 ms 35932 KB Output is correct
76 Correct 30 ms 35920 KB Output is correct
77 Correct 63 ms 38404 KB Output is correct
78 Correct 67 ms 38400 KB Output is correct
79 Correct 75 ms 38408 KB Output is correct
80 Correct 71 ms 38444 KB Output is correct
81 Correct 63 ms 38432 KB Output is correct
82 Correct 64 ms 38408 KB Output is correct
83 Correct 70 ms 38404 KB Output is correct
84 Correct 63 ms 38408 KB Output is correct
85 Correct 68 ms 38404 KB Output is correct
86 Correct 63 ms 38424 KB Output is correct
87 Correct 62 ms 38408 KB Output is correct
88 Correct 75 ms 38400 KB Output is correct
89 Correct 63 ms 38408 KB Output is correct
90 Correct 64 ms 38400 KB Output is correct
91 Correct 74 ms 38448 KB Output is correct
92 Correct 64 ms 38404 KB Output is correct
93 Correct 1235 ms 48680 KB Output is correct
94 Correct 1291 ms 48620 KB Output is correct
95 Correct 1476 ms 48420 KB Output is correct
96 Correct 1536 ms 48652 KB Output is correct
97 Correct 1355 ms 48372 KB Output is correct
98 Correct 1343 ms 48556 KB Output is correct
99 Correct 163 ms 39288 KB Output is correct
100 Correct 154 ms 39488 KB Output is correct
101 Correct 176 ms 39416 KB Output is correct
102 Correct 153 ms 39488 KB Output is correct
103 Correct 421 ms 43716 KB Output is correct
104 Correct 511 ms 43588 KB Output is correct
105 Correct 437 ms 43688 KB Output is correct
106 Correct 594 ms 43556 KB Output is correct
107 Correct 1216 ms 48508 KB Output is correct
108 Correct 1399 ms 48664 KB Output is correct
109 Correct 1263 ms 48380 KB Output is correct
110 Correct 1231 ms 48460 KB Output is correct
111 Correct 181 ms 39292 KB Output is correct
112 Correct 157 ms 39292 KB Output is correct
113 Correct 163 ms 39492 KB Output is correct
114 Correct 175 ms 39288 KB Output is correct
115 Correct 159 ms 39468 KB Output is correct
116 Correct 152 ms 39492 KB Output is correct
117 Correct 157 ms 39556 KB Output is correct
118 Correct 152 ms 39480 KB Output is correct
119 Correct 154 ms 39492 KB Output is correct
120 Correct 186 ms 39288 KB Output is correct
121 Correct 157 ms 39408 KB Output is correct
122 Correct 457 ms 43572 KB Output is correct
123 Correct 447 ms 43564 KB Output is correct
124 Correct 546 ms 43736 KB Output is correct
125 Correct 445 ms 43576 KB Output is correct
126 Correct 507 ms 43556 KB Output is correct
127 Correct 484 ms 43552 KB Output is correct
128 Correct 414 ms 43556 KB Output is correct
129 Correct 563 ms 43556 KB Output is correct
130 Correct 467 ms 43528 KB Output is correct
131 Correct 404 ms 43472 KB Output is correct
132 Correct 475 ms 43592 KB Output is correct
133 Correct 453 ms 43688 KB Output is correct
134 Correct 505 ms 43568 KB Output is correct
135 Correct 482 ms 43560 KB Output is correct
136 Correct 498 ms 43560 KB Output is correct
137 Correct 466 ms 43688 KB Output is correct
138 Correct 431 ms 43560 KB Output is correct
139 Correct 435 ms 43692 KB Output is correct
140 Correct 455 ms 43552 KB Output is correct
141 Correct 408 ms 43576 KB Output is correct
142 Correct 1422 ms 48372 KB Output is correct
143 Correct 1371 ms 48512 KB Output is correct
144 Correct 1435 ms 48380 KB Output is correct
145 Correct 1456 ms 48692 KB Output is correct
146 Correct 1325 ms 48384 KB Output is correct
147 Correct 1431 ms 48504 KB Output is correct
148 Correct 1358 ms 48380 KB Output is correct
149 Correct 1294 ms 48544 KB Output is correct
150 Correct 1477 ms 48520 KB Output is correct
151 Correct 1566 ms 48524 KB Output is correct
152 Correct 1490 ms 48400 KB Output is correct
153 Correct 1371 ms 48388 KB Output is correct
154 Correct 1363 ms 48380 KB Output is correct
155 Correct 1414 ms 48376 KB Output is correct
156 Correct 1317 ms 48380 KB Output is correct
157 Correct 1341 ms 48380 KB Output is correct
158 Correct 1274 ms 48512 KB Output is correct
159 Correct 1447 ms 48520 KB Output is correct
160 Correct 1392 ms 48372 KB Output is correct
161 Correct 1206 ms 48380 KB Output is correct
162 Correct 1363 ms 48504 KB Output is correct
163 Correct 1405 ms 48508 KB Output is correct
164 Correct 1319 ms 48376 KB Output is correct
165 Correct 1311 ms 48368 KB Output is correct
166 Correct 1239 ms 48332 KB Output is correct
167 Correct 1396 ms 48548 KB Output is correct