답안 #967734

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
967734 2024-04-22T17:34:10 Z mannshah1211 Paths (BOI18_paths) C++17
100 / 100
373 ms 70736 KB
/**
 *  author: hashman
 *  created: 
**/

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> c(n);
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    --c[i];
  }
  vector<vector<int>> g(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<vector<int64_t>> dp(n, vector<int64_t>(1 << k));
  for (int i = 0; i < n; i++) {
    dp[i][1 << c[i]] = 1;
  }
  for (int j = 1; j < (1 << k); j++) {
    for (int i = 0; i < n; i++) {
      if (j & (1 << c[i])) {
        for (int prv : g[i]) {
          dp[i][j] += dp[prv][j - (1 << c[i])];
        }
      }
    }
  }
  int64_t ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j < (1 << k); j++) {
      ans += dp[i][j];
    }
  }
  cout << ans - n << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 620 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 452 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 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 6996 KB Output is correct
2 Correct 34 ms 6344 KB Output is correct
3 Correct 274 ms 52232 KB Output is correct
4 Correct 61 ms 10576 KB Output is correct
5 Correct 59 ms 10192 KB Output is correct
6 Correct 159 ms 37320 KB Output is correct
7 Correct 296 ms 51864 KB Output is correct
8 Correct 234 ms 52704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 620 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 452 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 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 43 ms 6996 KB Output is correct
12 Correct 34 ms 6344 KB Output is correct
13 Correct 274 ms 52232 KB Output is correct
14 Correct 61 ms 10576 KB Output is correct
15 Correct 59 ms 10192 KB Output is correct
16 Correct 159 ms 37320 KB Output is correct
17 Correct 296 ms 51864 KB Output is correct
18 Correct 234 ms 52704 KB Output is correct
19 Correct 44 ms 7000 KB Output is correct
20 Correct 39 ms 6232 KB Output is correct
21 Correct 239 ms 51800 KB Output is correct
22 Correct 60 ms 10532 KB Output is correct
23 Correct 57 ms 10192 KB Output is correct
24 Correct 164 ms 37576 KB Output is correct
25 Correct 252 ms 51900 KB Output is correct
26 Correct 252 ms 52708 KB Output is correct
27 Correct 49 ms 6228 KB Output is correct
28 Correct 53 ms 8788 KB Output is correct
29 Correct 373 ms 70736 KB Output is correct
30 Correct 240 ms 39112 KB Output is correct
31 Correct 224 ms 39096 KB Output is correct
32 Correct 361 ms 70720 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 17 ms 2328 KB Output is correct
3 Correct 12 ms 2136 KB Output is correct
4 Correct 51 ms 17488 KB Output is correct
5 Correct 43 ms 18124 KB Output is correct
6 Correct 154 ms 36176 KB Output is correct
7 Correct 12 ms 2140 KB Output is correct
8 Correct 87 ms 23632 KB Output is correct
9 Correct 68 ms 24268 KB Output is correct
10 Correct 81 ms 24384 KB Output is correct
11 Correct 57 ms 19148 KB Output is correct
12 Correct 75 ms 28232 KB Output is correct
13 Correct 83 ms 19284 KB Output is correct
14 Correct 131 ms 36184 KB Output is correct
15 Correct 133 ms 36360 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct