Submission #348742

# Submission time Handle Problem Language Result Execution time Memory
348742 2021-01-15T15:56:12 Z doowey Amusement Park (CEOI19_amusementpark) C++14
42 / 100
43 ms 18796 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = 18;
const int MOD = 998244353;
int mask[N];
map<int,int> dp[1<<N];

void add(int &a, int b){
    a += b;
}

int main(){
    fastIO;
    int n,m;
    cin >> n >> m;
    int u, v;
    for(int i = 1; i <= m; i ++ ){
        cin >> u >> v;
        u--;
        v--;
        mask[u] |= (1 << v);
        mask[v] |= (1 << u);
    }
    dp[0][(1<<n)-1]=1;
    int cur, msk;
    int val;
    int nah;
    for(int i = 0 ; i < (1 << n); i ++ ){
        for(auto x : dp[i]){
            cur = i;
            msk = x.fi;
            val = x.se;
            for(int nx = 0 ; nx < n; nx ++ ){
                if((msk & (1 << nx))){
                    nah = (msk & (((1<<n)-1)-((1<<(nx+1))-1)));
                    nah = (nah | ((mask[nx]|i)^i));
                    add(dp[(i|(1<<nx))][nah],val);
                }
            }
        }
    }
    int sol = dp[(1<<n)-1][0];
    sol = (sol * 1ll * m) % MOD;
    sol = (sol * 1ll * (MOD+1)/2) % MOD;
    cout << sol << "\n";
    return 0;
}

Compilation message

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:35:9: warning: variable 'cur' set but not used [-Wunused-but-set-variable]
   35 |     int cur, msk;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 12652 KB Output is correct
2 Correct 9 ms 12652 KB Output is correct
3 Correct 9 ms 12652 KB Output is correct
4 Correct 9 ms 12652 KB Output is correct
5 Correct 9 ms 12652 KB Output is correct
6 Correct 9 ms 12652 KB Output is correct
7 Correct 9 ms 12652 KB Output is correct
8 Correct 9 ms 12652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 12652 KB Output is correct
2 Correct 9 ms 12652 KB Output is correct
3 Correct 9 ms 12652 KB Output is correct
4 Correct 9 ms 12652 KB Output is correct
5 Correct 9 ms 12652 KB Output is correct
6 Correct 9 ms 12652 KB Output is correct
7 Correct 9 ms 12652 KB Output is correct
8 Correct 9 ms 12652 KB Output is correct
9 Correct 9 ms 12652 KB Output is correct
10 Correct 9 ms 12652 KB Output is correct
11 Correct 9 ms 12652 KB Output is correct
12 Correct 9 ms 12652 KB Output is correct
13 Correct 9 ms 12672 KB Output is correct
14 Correct 9 ms 12652 KB Output is correct
15 Correct 9 ms 12652 KB Output is correct
16 Correct 9 ms 12652 KB Output is correct
17 Correct 9 ms 12652 KB Output is correct
18 Correct 9 ms 12652 KB Output is correct
19 Correct 9 ms 12652 KB Output is correct
20 Correct 9 ms 12652 KB Output is correct
21 Correct 9 ms 12652 KB Output is correct
22 Correct 9 ms 12652 KB Output is correct
23 Correct 9 ms 12652 KB Output is correct
24 Correct 9 ms 12652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 12652 KB Output is correct
2 Correct 9 ms 12652 KB Output is correct
3 Correct 9 ms 12652 KB Output is correct
4 Correct 9 ms 12652 KB Output is correct
5 Correct 9 ms 12652 KB Output is correct
6 Correct 9 ms 12652 KB Output is correct
7 Correct 9 ms 12652 KB Output is correct
8 Correct 9 ms 12652 KB Output is correct
9 Correct 9 ms 12652 KB Output is correct
10 Correct 9 ms 12652 KB Output is correct
11 Correct 9 ms 12652 KB Output is correct
12 Correct 9 ms 12652 KB Output is correct
13 Correct 9 ms 12672 KB Output is correct
14 Correct 9 ms 12652 KB Output is correct
15 Correct 9 ms 12652 KB Output is correct
16 Correct 9 ms 12652 KB Output is correct
17 Correct 9 ms 12652 KB Output is correct
18 Correct 9 ms 12652 KB Output is correct
19 Correct 9 ms 12652 KB Output is correct
20 Correct 9 ms 12652 KB Output is correct
21 Correct 9 ms 12652 KB Output is correct
22 Correct 9 ms 12652 KB Output is correct
23 Correct 9 ms 12652 KB Output is correct
24 Correct 9 ms 12652 KB Output is correct
25 Correct 9 ms 12672 KB Output is correct
26 Correct 9 ms 12652 KB Output is correct
27 Correct 9 ms 12652 KB Output is correct
28 Correct 9 ms 12652 KB Output is correct
29 Correct 9 ms 12652 KB Output is correct
30 Correct 9 ms 12652 KB Output is correct
31 Correct 9 ms 12652 KB Output is correct
32 Correct 9 ms 12652 KB Output is correct
33 Correct 9 ms 12652 KB Output is correct
34 Correct 9 ms 12660 KB Output is correct
35 Correct 9 ms 12652 KB Output is correct
36 Correct 9 ms 12652 KB Output is correct
37 Correct 9 ms 12652 KB Output is correct
38 Correct 9 ms 12652 KB Output is correct
39 Correct 9 ms 12652 KB Output is correct
40 Correct 9 ms 12652 KB Output is correct
41 Correct 9 ms 12652 KB Output is correct
42 Correct 9 ms 12652 KB Output is correct
43 Correct 9 ms 12652 KB Output is correct
44 Correct 9 ms 12652 KB Output is correct
45 Correct 9 ms 12672 KB Output is correct
46 Correct 9 ms 12652 KB Output is correct
47 Correct 9 ms 12652 KB Output is correct
48 Correct 9 ms 12652 KB Output is correct
49 Correct 9 ms 12780 KB Output is correct
50 Correct 9 ms 12652 KB Output is correct
51 Correct 9 ms 12652 KB Output is correct
52 Correct 9 ms 12652 KB Output is correct
53 Correct 9 ms 12780 KB Output is correct
54 Correct 9 ms 12780 KB Output is correct
55 Correct 9 ms 12908 KB Output is correct
56 Correct 10 ms 12780 KB Output is correct
57 Correct 9 ms 12780 KB Output is correct
58 Correct 9 ms 12800 KB Output is correct
59 Correct 9 ms 12780 KB Output is correct
60 Correct 9 ms 12652 KB Output is correct
61 Correct 9 ms 12780 KB Output is correct
62 Correct 9 ms 12780 KB Output is correct
63 Correct 9 ms 12780 KB Output is correct
64 Correct 9 ms 12780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 12652 KB Output is correct
2 Correct 9 ms 12652 KB Output is correct
3 Correct 9 ms 12652 KB Output is correct
4 Correct 9 ms 12652 KB Output is correct
5 Correct 9 ms 12652 KB Output is correct
6 Correct 9 ms 12652 KB Output is correct
7 Correct 9 ms 12652 KB Output is correct
8 Correct 9 ms 12652 KB Output is correct
9 Correct 9 ms 12652 KB Output is correct
10 Correct 9 ms 12652 KB Output is correct
11 Correct 9 ms 12652 KB Output is correct
12 Correct 9 ms 12652 KB Output is correct
13 Correct 9 ms 12672 KB Output is correct
14 Correct 9 ms 12652 KB Output is correct
15 Correct 9 ms 12652 KB Output is correct
16 Correct 9 ms 12652 KB Output is correct
17 Correct 9 ms 12652 KB Output is correct
18 Correct 9 ms 12652 KB Output is correct
19 Correct 9 ms 12652 KB Output is correct
20 Correct 9 ms 12652 KB Output is correct
21 Correct 9 ms 12652 KB Output is correct
22 Correct 9 ms 12652 KB Output is correct
23 Correct 9 ms 12652 KB Output is correct
24 Correct 9 ms 12652 KB Output is correct
25 Correct 9 ms 12672 KB Output is correct
26 Correct 9 ms 12652 KB Output is correct
27 Correct 9 ms 12652 KB Output is correct
28 Correct 9 ms 12652 KB Output is correct
29 Correct 9 ms 12652 KB Output is correct
30 Correct 9 ms 12652 KB Output is correct
31 Correct 9 ms 12652 KB Output is correct
32 Correct 9 ms 12652 KB Output is correct
33 Correct 9 ms 12652 KB Output is correct
34 Correct 9 ms 12660 KB Output is correct
35 Correct 9 ms 12652 KB Output is correct
36 Correct 9 ms 12652 KB Output is correct
37 Correct 9 ms 12652 KB Output is correct
38 Correct 9 ms 12652 KB Output is correct
39 Correct 9 ms 12652 KB Output is correct
40 Correct 9 ms 12652 KB Output is correct
41 Correct 9 ms 12652 KB Output is correct
42 Correct 9 ms 12652 KB Output is correct
43 Correct 9 ms 12652 KB Output is correct
44 Correct 9 ms 12652 KB Output is correct
45 Correct 9 ms 12672 KB Output is correct
46 Correct 9 ms 12652 KB Output is correct
47 Correct 9 ms 12652 KB Output is correct
48 Correct 9 ms 12652 KB Output is correct
49 Correct 9 ms 12780 KB Output is correct
50 Correct 9 ms 12652 KB Output is correct
51 Correct 9 ms 12652 KB Output is correct
52 Correct 9 ms 12652 KB Output is correct
53 Correct 9 ms 12780 KB Output is correct
54 Correct 9 ms 12780 KB Output is correct
55 Correct 9 ms 12908 KB Output is correct
56 Correct 10 ms 12780 KB Output is correct
57 Correct 9 ms 12780 KB Output is correct
58 Correct 9 ms 12800 KB Output is correct
59 Correct 9 ms 12780 KB Output is correct
60 Correct 9 ms 12652 KB Output is correct
61 Correct 9 ms 12780 KB Output is correct
62 Correct 9 ms 12780 KB Output is correct
63 Correct 9 ms 12780 KB Output is correct
64 Correct 9 ms 12780 KB Output is correct
65 Correct 32 ms 17396 KB Output is correct
66 Correct 43 ms 18796 KB Output is correct
67 Correct 39 ms 18304 KB Output is correct
68 Incorrect 39 ms 18028 KB Output isn't correct
69 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 12652 KB Output is correct
2 Correct 9 ms 12652 KB Output is correct
3 Correct 9 ms 12652 KB Output is correct
4 Correct 9 ms 12652 KB Output is correct
5 Correct 9 ms 12652 KB Output is correct
6 Correct 9 ms 12652 KB Output is correct
7 Correct 9 ms 12652 KB Output is correct
8 Correct 9 ms 12652 KB Output is correct
9 Correct 9 ms 12652 KB Output is correct
10 Correct 9 ms 12652 KB Output is correct
11 Correct 9 ms 12652 KB Output is correct
12 Correct 9 ms 12652 KB Output is correct
13 Correct 9 ms 12672 KB Output is correct
14 Correct 9 ms 12652 KB Output is correct
15 Correct 9 ms 12652 KB Output is correct
16 Correct 9 ms 12652 KB Output is correct
17 Correct 9 ms 12652 KB Output is correct
18 Correct 9 ms 12652 KB Output is correct
19 Correct 9 ms 12652 KB Output is correct
20 Correct 9 ms 12652 KB Output is correct
21 Correct 9 ms 12652 KB Output is correct
22 Correct 9 ms 12652 KB Output is correct
23 Correct 9 ms 12652 KB Output is correct
24 Correct 9 ms 12652 KB Output is correct
25 Correct 9 ms 12672 KB Output is correct
26 Correct 9 ms 12652 KB Output is correct
27 Correct 9 ms 12652 KB Output is correct
28 Correct 9 ms 12652 KB Output is correct
29 Correct 9 ms 12652 KB Output is correct
30 Correct 9 ms 12652 KB Output is correct
31 Correct 9 ms 12652 KB Output is correct
32 Correct 9 ms 12652 KB Output is correct
33 Correct 9 ms 12652 KB Output is correct
34 Correct 9 ms 12660 KB Output is correct
35 Correct 9 ms 12652 KB Output is correct
36 Correct 9 ms 12652 KB Output is correct
37 Correct 9 ms 12652 KB Output is correct
38 Correct 9 ms 12652 KB Output is correct
39 Correct 9 ms 12652 KB Output is correct
40 Correct 9 ms 12652 KB Output is correct
41 Correct 9 ms 12652 KB Output is correct
42 Correct 9 ms 12652 KB Output is correct
43 Correct 9 ms 12652 KB Output is correct
44 Correct 9 ms 12652 KB Output is correct
45 Correct 9 ms 12672 KB Output is correct
46 Correct 9 ms 12652 KB Output is correct
47 Correct 9 ms 12652 KB Output is correct
48 Correct 9 ms 12652 KB Output is correct
49 Correct 9 ms 12780 KB Output is correct
50 Correct 9 ms 12652 KB Output is correct
51 Correct 9 ms 12652 KB Output is correct
52 Correct 9 ms 12652 KB Output is correct
53 Correct 9 ms 12780 KB Output is correct
54 Correct 9 ms 12780 KB Output is correct
55 Correct 9 ms 12908 KB Output is correct
56 Correct 10 ms 12780 KB Output is correct
57 Correct 9 ms 12780 KB Output is correct
58 Correct 9 ms 12800 KB Output is correct
59 Correct 9 ms 12780 KB Output is correct
60 Correct 9 ms 12652 KB Output is correct
61 Correct 9 ms 12780 KB Output is correct
62 Correct 9 ms 12780 KB Output is correct
63 Correct 9 ms 12780 KB Output is correct
64 Correct 9 ms 12780 KB Output is correct
65 Correct 32 ms 17396 KB Output is correct
66 Correct 43 ms 18796 KB Output is correct
67 Correct 39 ms 18304 KB Output is correct
68 Incorrect 39 ms 18028 KB Output isn't correct
69 Halted 0 ms 0 KB -