Submission #983410

# Submission time Handle Problem Language Result Execution time Memory
983410 2024-05-15T12:05:38 Z duckindog Amusement Park (CEOI19_amusementpark) C++17
19 / 100
100 ms 10836 KB
#include <bits/stdc++.h>
 
using namespace std;

const int N = 18 + 10,
          M = 998'244'353;
int n, m;

int32_t main() { 
  cin.tie(0)->sync_with_stdio(0);
 
  cin >> n >> m;
  vector<int> a(m + 1), b(m + 1);
  for (int i = 1; i <= m; ++i) cin >> a[i] >> b[i];
 
  long long answer = 0;
  vector<int> vt(n); iota(vt.begin(), vt.end(), 1);
  set<long long> mk;
  
  do { 
    vector<int> p(n + 1);  
    for (int i = 0; i < n; ++i) p[vt[i]] = i;
    long long mask = 0;
    for (int i = 1; i <= m; ++i) if (p[a[i]] > p[b[i]]) mask |= (1 << i - 1);
    if (!mk.count(mask)) {
      answer += __builtin_popcount(mask);
      mk.insert(mask);
    }
  } while (next_permutation(vt.begin(), vt.end()));
  cout << answer % M << "\n";
}

Compilation message

amusementpark.cpp: In function 'int32_t main()':
amusementpark.cpp:24:73: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   24 |     for (int i = 1; i <= m; ++i) if (p[a[i]] > p[b[i]]) mask |= (1 << i - 1);
      |                                                                       ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 424 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 424 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 2 ms 456 KB Output is correct
34 Correct 4 ms 348 KB Output is correct
35 Correct 6 ms 604 KB Output is correct
36 Correct 7 ms 884 KB Output is correct
37 Correct 11 ms 1372 KB Output is correct
38 Correct 12 ms 2136 KB Output is correct
39 Correct 16 ms 452 KB Output is correct
40 Correct 19 ms 600 KB Output is correct
41 Correct 23 ms 348 KB Output is correct
42 Correct 31 ms 604 KB Output is correct
43 Correct 41 ms 1616 KB Output is correct
44 Correct 56 ms 2928 KB Output is correct
45 Correct 80 ms 5956 KB Output is correct
46 Correct 90 ms 10836 KB Output is correct
47 Incorrect 100 ms 10576 KB Output isn't correct
48 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 424 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 2 ms 456 KB Output is correct
34 Correct 4 ms 348 KB Output is correct
35 Correct 6 ms 604 KB Output is correct
36 Correct 7 ms 884 KB Output is correct
37 Correct 11 ms 1372 KB Output is correct
38 Correct 12 ms 2136 KB Output is correct
39 Correct 16 ms 452 KB Output is correct
40 Correct 19 ms 600 KB Output is correct
41 Correct 23 ms 348 KB Output is correct
42 Correct 31 ms 604 KB Output is correct
43 Correct 41 ms 1616 KB Output is correct
44 Correct 56 ms 2928 KB Output is correct
45 Correct 80 ms 5956 KB Output is correct
46 Correct 90 ms 10836 KB Output is correct
47 Incorrect 100 ms 10576 KB Output isn't correct
48 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 424 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 2 ms 456 KB Output is correct
34 Correct 4 ms 348 KB Output is correct
35 Correct 6 ms 604 KB Output is correct
36 Correct 7 ms 884 KB Output is correct
37 Correct 11 ms 1372 KB Output is correct
38 Correct 12 ms 2136 KB Output is correct
39 Correct 16 ms 452 KB Output is correct
40 Correct 19 ms 600 KB Output is correct
41 Correct 23 ms 348 KB Output is correct
42 Correct 31 ms 604 KB Output is correct
43 Correct 41 ms 1616 KB Output is correct
44 Correct 56 ms 2928 KB Output is correct
45 Correct 80 ms 5956 KB Output is correct
46 Correct 90 ms 10836 KB Output is correct
47 Incorrect 100 ms 10576 KB Output isn't correct
48 Halted 0 ms 0 KB -