Submission #1062542

# Submission time Handle Problem Language Result Execution time Memory
1062542 2024-08-17T08:25:46 Z kunzaZa183 Amusement Park (CEOI19_amusementpark) C++17
19 / 100
3000 ms 89428 KB
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
signed main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  int n, m;
  cin >> n >> m;
  vector<int> ht(n);
  vector<pair<int, int>> vpii(m);
  for (auto &a : vpii) {
    cin >> a.first >> a.second;
    a.first--, a.second--;
  }
  iota(ht.begin(), ht.end(), 0);
  long long sumc = 0;
  const int mod = 998244353;
  set<long long> svi;

  auto hsh = [](vector<int> &vi) {
    int each = 11;
    long long cur = 0;
    for (auto a : vi) {
      cur *= each;
      cur += a;
    }
    return cur;
  };

  do {
    vector<int> real;
    int curs = 0;
    for (auto a : vpii) {
      if ((ht[a.first] > ht[a.second])) {
        curs++;
        real.emplace_back(a.second);
        real.emplace_back(a.first);
      }
      real.emplace_back(a.first);
      real.emplace_back(a.second);
    }
    auto it = svi.insert(hsh(real));
    if (it.second) {
      sumc += curs;
      sumc %= mod;
    }
  } while (next_permutation(ht.begin(), ht.end()));
  cout << sumc << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 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 344 KB Output is correct
10 Correct 1 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 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 376 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 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 344 KB Output is correct
10 Correct 1 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 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 376 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 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 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 460 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 3 ms 604 KB Output is correct
32 Correct 5 ms 348 KB Output is correct
33 Correct 7 ms 460 KB Output is correct
34 Correct 16 ms 344 KB Output is correct
35 Correct 13 ms 600 KB Output is correct
36 Correct 14 ms 860 KB Output is correct
37 Correct 19 ms 1372 KB Output is correct
38 Correct 23 ms 2272 KB Output is correct
39 Correct 39 ms 348 KB Output is correct
40 Correct 60 ms 436 KB Output is correct
41 Correct 79 ms 480 KB Output is correct
42 Correct 95 ms 592 KB Output is correct
43 Correct 120 ms 1752 KB Output is correct
44 Correct 151 ms 2900 KB Output is correct
45 Correct 182 ms 5968 KB Output is correct
46 Correct 219 ms 10836 KB Output is correct
47 Correct 288 ms 17292 KB Output is correct
48 Correct 57 ms 348 KB Output is correct
49 Correct 84 ms 604 KB Output is correct
50 Correct 86 ms 596 KB Output is correct
51 Correct 94 ms 592 KB Output is correct
52 Correct 434 ms 348 KB Output is correct
53 Correct 653 ms 344 KB Output is correct
54 Correct 898 ms 596 KB Output is correct
55 Correct 1181 ms 1872 KB Output is correct
56 Correct 1548 ms 8808 KB Output is correct
57 Correct 1968 ms 22636 KB Output is correct
58 Correct 2695 ms 48464 KB Output is correct
59 Execution timed out 3070 ms 89428 KB Time limit exceeded
60 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 344 KB Output is correct
10 Correct 1 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 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 376 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 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 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 460 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 3 ms 604 KB Output is correct
32 Correct 5 ms 348 KB Output is correct
33 Correct 7 ms 460 KB Output is correct
34 Correct 16 ms 344 KB Output is correct
35 Correct 13 ms 600 KB Output is correct
36 Correct 14 ms 860 KB Output is correct
37 Correct 19 ms 1372 KB Output is correct
38 Correct 23 ms 2272 KB Output is correct
39 Correct 39 ms 348 KB Output is correct
40 Correct 60 ms 436 KB Output is correct
41 Correct 79 ms 480 KB Output is correct
42 Correct 95 ms 592 KB Output is correct
43 Correct 120 ms 1752 KB Output is correct
44 Correct 151 ms 2900 KB Output is correct
45 Correct 182 ms 5968 KB Output is correct
46 Correct 219 ms 10836 KB Output is correct
47 Correct 288 ms 17292 KB Output is correct
48 Correct 57 ms 348 KB Output is correct
49 Correct 84 ms 604 KB Output is correct
50 Correct 86 ms 596 KB Output is correct
51 Correct 94 ms 592 KB Output is correct
52 Correct 434 ms 348 KB Output is correct
53 Correct 653 ms 344 KB Output is correct
54 Correct 898 ms 596 KB Output is correct
55 Correct 1181 ms 1872 KB Output is correct
56 Correct 1548 ms 8808 KB Output is correct
57 Correct 1968 ms 22636 KB Output is correct
58 Correct 2695 ms 48464 KB Output is correct
59 Execution timed out 3070 ms 89428 KB Time limit exceeded
60 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 344 KB Output is correct
10 Correct 1 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 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 376 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 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 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 460 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 3 ms 604 KB Output is correct
32 Correct 5 ms 348 KB Output is correct
33 Correct 7 ms 460 KB Output is correct
34 Correct 16 ms 344 KB Output is correct
35 Correct 13 ms 600 KB Output is correct
36 Correct 14 ms 860 KB Output is correct
37 Correct 19 ms 1372 KB Output is correct
38 Correct 23 ms 2272 KB Output is correct
39 Correct 39 ms 348 KB Output is correct
40 Correct 60 ms 436 KB Output is correct
41 Correct 79 ms 480 KB Output is correct
42 Correct 95 ms 592 KB Output is correct
43 Correct 120 ms 1752 KB Output is correct
44 Correct 151 ms 2900 KB Output is correct
45 Correct 182 ms 5968 KB Output is correct
46 Correct 219 ms 10836 KB Output is correct
47 Correct 288 ms 17292 KB Output is correct
48 Correct 57 ms 348 KB Output is correct
49 Correct 84 ms 604 KB Output is correct
50 Correct 86 ms 596 KB Output is correct
51 Correct 94 ms 592 KB Output is correct
52 Correct 434 ms 348 KB Output is correct
53 Correct 653 ms 344 KB Output is correct
54 Correct 898 ms 596 KB Output is correct
55 Correct 1181 ms 1872 KB Output is correct
56 Correct 1548 ms 8808 KB Output is correct
57 Correct 1968 ms 22636 KB Output is correct
58 Correct 2695 ms 48464 KB Output is correct
59 Execution timed out 3070 ms 89428 KB Time limit exceeded
60 Halted 0 ms 0 KB -