Submission #696196

# Submission time Handle Problem Language Result Execution time Memory
696196 2023-02-05T19:36:03 Z bdl Paths (BOI18_paths) C++17
100 / 100
260 ms 46380 KB
#include <iostream>
#include <vector>
using namespace std;

#define ll long long

inline int p2(const int& b) {
  return 1 << b;
}

const int N = 3e5, K = 5;

int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  static int c[N];
  for (int i = 0; i < n; i++)
    cin >> c[i], c[i]--;
  static vector<int> g[N];
  static ll f[1 << K][N];
  for (int h = 0; h < m; h++) {
    int i, j;
    cin >> i >> j, i--, j--;
    if (c[i] != c[j]) {
      g[i].push_back(j), g[j].push_back(i);
      f[p2(c[i]) | p2(c[j])][i] += 1, f[p2(c[i]) | p2(c[j])][j] += 1;
    }
  }
  ll ans = 0;
  for (int b = 0; b < 1 << k; b++)
    for (int i = 0; i < n; i++)
      if (f[b][i]) {
        ans += f[b][i];
        for (int j : g[i])
          if (!(b & p2(c[j])))
            f[b | p2(c[j])][j] += f[b][i];
      }
  cout << ans << '\n';
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7380 KB Output is correct
2 Correct 4 ms 7372 KB Output is correct
3 Correct 5 ms 7368 KB Output is correct
4 Correct 4 ms 7380 KB Output is correct
5 Correct 4 ms 7380 KB Output is correct
6 Correct 4 ms 7380 KB Output is correct
7 Correct 5 ms 7492 KB Output is correct
8 Correct 4 ms 7424 KB Output is correct
9 Correct 4 ms 7380 KB Output is correct
10 Correct 3 ms 7380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 13128 KB Output is correct
2 Correct 50 ms 11720 KB Output is correct
3 Correct 198 ms 29408 KB Output is correct
4 Correct 67 ms 13492 KB Output is correct
5 Correct 46 ms 10800 KB Output is correct
6 Correct 137 ms 24324 KB Output is correct
7 Correct 189 ms 29388 KB Output is correct
8 Correct 209 ms 30164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7380 KB Output is correct
2 Correct 4 ms 7372 KB Output is correct
3 Correct 5 ms 7368 KB Output is correct
4 Correct 4 ms 7380 KB Output is correct
5 Correct 4 ms 7380 KB Output is correct
6 Correct 4 ms 7380 KB Output is correct
7 Correct 5 ms 7492 KB Output is correct
8 Correct 4 ms 7424 KB Output is correct
9 Correct 4 ms 7380 KB Output is correct
10 Correct 3 ms 7380 KB Output is correct
11 Correct 65 ms 13128 KB Output is correct
12 Correct 50 ms 11720 KB Output is correct
13 Correct 198 ms 29408 KB Output is correct
14 Correct 67 ms 13492 KB Output is correct
15 Correct 46 ms 10800 KB Output is correct
16 Correct 137 ms 24324 KB Output is correct
17 Correct 189 ms 29388 KB Output is correct
18 Correct 209 ms 30164 KB Output is correct
19 Correct 61 ms 13200 KB Output is correct
20 Correct 51 ms 11644 KB Output is correct
21 Correct 193 ms 29436 KB Output is correct
22 Correct 76 ms 13440 KB Output is correct
23 Correct 47 ms 10796 KB Output is correct
24 Correct 137 ms 24268 KB Output is correct
25 Correct 202 ms 29352 KB Output is correct
26 Correct 200 ms 30176 KB Output is correct
27 Correct 62 ms 13392 KB Output is correct
28 Correct 79 ms 13756 KB Output is correct
29 Correct 260 ms 46256 KB Output is correct
30 Correct 180 ms 29936 KB Output is correct
31 Correct 197 ms 28916 KB Output is correct
32 Correct 253 ms 46380 KB Output is correct
33 Correct 4 ms 7380 KB Output is correct
34 Correct 5 ms 7500 KB Output is correct
35 Correct 4 ms 7380 KB Output is correct
36 Correct 4 ms 7380 KB Output is correct
37 Correct 5 ms 7368 KB Output is correct
38 Correct 5 ms 7368 KB Output is correct
39 Correct 4 ms 7380 KB Output is correct
40 Correct 6 ms 7380 KB Output is correct
41 Correct 4 ms 7380 KB Output is correct
42 Correct 4 ms 7380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7508 KB Output is correct
2 Correct 35 ms 9428 KB Output is correct
3 Correct 20 ms 9248 KB Output is correct
4 Correct 52 ms 14552 KB Output is correct
5 Correct 39 ms 13768 KB Output is correct
6 Correct 83 ms 32140 KB Output is correct
7 Correct 25 ms 9272 KB Output is correct
8 Correct 61 ms 20168 KB Output is correct
9 Correct 47 ms 16476 KB Output is correct
10 Correct 63 ms 17220 KB Output is correct
11 Correct 56 ms 20704 KB Output is correct
12 Correct 57 ms 17296 KB Output is correct
13 Correct 57 ms 18164 KB Output is correct
14 Correct 84 ms 32148 KB Output is correct
15 Correct 80 ms 32324 KB Output is correct
16 Correct 4 ms 7488 KB Output is correct
17 Correct 4 ms 7380 KB Output is correct
18 Correct 4 ms 7392 KB Output is correct
19 Correct 4 ms 7380 KB Output is correct
20 Correct 4 ms 7380 KB Output is correct
21 Correct 4 ms 7360 KB Output is correct
22 Correct 4 ms 7380 KB Output is correct
23 Correct 4 ms 7500 KB Output is correct
24 Correct 4 ms 7368 KB Output is correct
25 Correct 4 ms 7380 KB Output is correct