Submission #598661

# Submission time Handle Problem Language Result Execution time Memory
598661 2022-07-18T16:24:08 Z Valaki2 Amusement Park (CEOI19_amusementpark) C++14
42 / 100
3000 ms 162144 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

const int mod = 998244353;
const int logn = 60;

int n, m;
vector<int> a;
vector<int> b;
unordered_set<int> s;
int po[logn];

void solve() {
    po[0] = 1;
    for(int i = 1; i < logn; i++) {
        po[i] = 2 * po[i - 1];
    }
    cin >> n >> m;
    a.assign(m, 0);
    b.assign(m, 0);
    for(int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    vector<int> v(n, 0);
    for(int i = 0; i < n; i++) {
        v[i] = i;
    }
    do {
        int c = 0;
        for(int i = 0; i < m; i++) {
            c |= (v[a[i]] > v[b[i]]) * po[i];
        }
        s.insert(c);
    } while(next_permutation(v.begin(), v.end()));
    int ans = 0;
    for(int x : s) {
        ans = ans + __builtin_popcountll(x);
    }
    ans %= mod;
    cout << ans << "\n";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 284 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 2 ms 468 KB Output is correct
36 Correct 3 ms 852 KB Output is correct
37 Correct 6 ms 1364 KB Output is correct
38 Correct 7 ms 1868 KB Output is correct
39 Correct 6 ms 212 KB Output is correct
40 Correct 6 ms 212 KB Output is correct
41 Correct 9 ms 360 KB Output is correct
42 Correct 13 ms 584 KB Output is correct
43 Correct 19 ms 1500 KB Output is correct
44 Correct 23 ms 2640 KB Output is correct
45 Correct 37 ms 5316 KB Output is correct
46 Correct 67 ms 10036 KB Output is correct
47 Correct 145 ms 19596 KB Output is correct
48 Correct 9 ms 324 KB Output is correct
49 Correct 10 ms 468 KB Output is correct
50 Correct 11 ms 452 KB Output is correct
51 Correct 14 ms 468 KB Output is correct
52 Correct 45 ms 212 KB Output is correct
53 Correct 67 ms 336 KB Output is correct
54 Correct 108 ms 580 KB Output is correct
55 Correct 166 ms 1572 KB Output is correct
56 Correct 203 ms 9824 KB Output is correct
57 Correct 400 ms 20800 KB Output is correct
58 Correct 788 ms 43752 KB Output is correct
59 Correct 1364 ms 86268 KB Output is correct
60 Correct 2297 ms 162144 KB Output is correct
61 Correct 62 ms 356 KB Output is correct
62 Correct 105 ms 872 KB Output is correct
63 Correct 105 ms 888 KB Output is correct
64 Correct 127 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 284 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 2 ms 468 KB Output is correct
36 Correct 3 ms 852 KB Output is correct
37 Correct 6 ms 1364 KB Output is correct
38 Correct 7 ms 1868 KB Output is correct
39 Correct 6 ms 212 KB Output is correct
40 Correct 6 ms 212 KB Output is correct
41 Correct 9 ms 360 KB Output is correct
42 Correct 13 ms 584 KB Output is correct
43 Correct 19 ms 1500 KB Output is correct
44 Correct 23 ms 2640 KB Output is correct
45 Correct 37 ms 5316 KB Output is correct
46 Correct 67 ms 10036 KB Output is correct
47 Correct 145 ms 19596 KB Output is correct
48 Correct 9 ms 324 KB Output is correct
49 Correct 10 ms 468 KB Output is correct
50 Correct 11 ms 452 KB Output is correct
51 Correct 14 ms 468 KB Output is correct
52 Correct 45 ms 212 KB Output is correct
53 Correct 67 ms 336 KB Output is correct
54 Correct 108 ms 580 KB Output is correct
55 Correct 166 ms 1572 KB Output is correct
56 Correct 203 ms 9824 KB Output is correct
57 Correct 400 ms 20800 KB Output is correct
58 Correct 788 ms 43752 KB Output is correct
59 Correct 1364 ms 86268 KB Output is correct
60 Correct 2297 ms 162144 KB Output is correct
61 Correct 62 ms 356 KB Output is correct
62 Correct 105 ms 872 KB Output is correct
63 Correct 105 ms 888 KB Output is correct
64 Correct 127 ms 888 KB Output is correct
65 Execution timed out 3061 ms 10004 KB Time limit exceeded
66 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 284 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 2 ms 468 KB Output is correct
36 Correct 3 ms 852 KB Output is correct
37 Correct 6 ms 1364 KB Output is correct
38 Correct 7 ms 1868 KB Output is correct
39 Correct 6 ms 212 KB Output is correct
40 Correct 6 ms 212 KB Output is correct
41 Correct 9 ms 360 KB Output is correct
42 Correct 13 ms 584 KB Output is correct
43 Correct 19 ms 1500 KB Output is correct
44 Correct 23 ms 2640 KB Output is correct
45 Correct 37 ms 5316 KB Output is correct
46 Correct 67 ms 10036 KB Output is correct
47 Correct 145 ms 19596 KB Output is correct
48 Correct 9 ms 324 KB Output is correct
49 Correct 10 ms 468 KB Output is correct
50 Correct 11 ms 452 KB Output is correct
51 Correct 14 ms 468 KB Output is correct
52 Correct 45 ms 212 KB Output is correct
53 Correct 67 ms 336 KB Output is correct
54 Correct 108 ms 580 KB Output is correct
55 Correct 166 ms 1572 KB Output is correct
56 Correct 203 ms 9824 KB Output is correct
57 Correct 400 ms 20800 KB Output is correct
58 Correct 788 ms 43752 KB Output is correct
59 Correct 1364 ms 86268 KB Output is correct
60 Correct 2297 ms 162144 KB Output is correct
61 Correct 62 ms 356 KB Output is correct
62 Correct 105 ms 872 KB Output is correct
63 Correct 105 ms 888 KB Output is correct
64 Correct 127 ms 888 KB Output is correct
65 Execution timed out 3061 ms 10004 KB Time limit exceeded
66 Halted 0 ms 0 KB -