답안 #1092800

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1092800 2024-09-25T07:16:55 Z juicy Paths (BOI18_paths) C++17
100 / 100
240 ms 70776 KB
#include <bits/stdc++.h>

using namespace std;

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

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);

  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);
  while (m--) {
    int u, v; cin >> u >> v; --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  long long res = 0;
  vector dp(n, vector<long long>(1 << k));
  for (int i = 0; i < n; ++i) {
    dp[i][1 << c[i]] = 1;
  }
  for (int m = 1; m < 1 << k; ++m) {
    for (int i = 0; i < n; ++i) {
      if (dp[i][m]) {
        for (int j : g[i]) {
          if (!(m >> c[j] & 1)) {
            dp[j][m + (1 << c[j])] += dp[i][m];
          }
        }
        if (__builtin_popcount(m) > 1) {
          res += dp[i][m];
        }
      }
    }
  }
  cout << res;
  return 0;
}
# 결과 실행 시간 메모리 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 460 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
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 7148 KB Output is correct
2 Correct 35 ms 6228 KB Output is correct
3 Correct 152 ms 51960 KB Output is correct
4 Correct 56 ms 10576 KB Output is correct
5 Correct 58 ms 10088 KB Output is correct
6 Correct 116 ms 37320 KB Output is correct
7 Correct 172 ms 51912 KB Output is correct
8 Correct 170 ms 52560 KB Output is correct
# 결과 실행 시간 메모리 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 460 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 44 ms 7148 KB Output is correct
12 Correct 35 ms 6228 KB Output is correct
13 Correct 152 ms 51960 KB Output is correct
14 Correct 56 ms 10576 KB Output is correct
15 Correct 58 ms 10088 KB Output is correct
16 Correct 116 ms 37320 KB Output is correct
17 Correct 172 ms 51912 KB Output is correct
18 Correct 170 ms 52560 KB Output is correct
19 Correct 46 ms 7136 KB Output is correct
20 Correct 37 ms 6224 KB Output is correct
21 Correct 163 ms 51792 KB Output is correct
22 Correct 59 ms 10580 KB Output is correct
23 Correct 54 ms 10064 KB Output is correct
24 Correct 109 ms 37316 KB Output is correct
25 Correct 188 ms 51796 KB Output is correct
26 Correct 178 ms 52564 KB Output is correct
27 Correct 49 ms 6236 KB Output is correct
28 Correct 66 ms 8784 KB Output is correct
29 Correct 240 ms 70576 KB Output is correct
30 Correct 149 ms 38852 KB Output is correct
31 Correct 141 ms 38860 KB Output is correct
32 Correct 236 ms 70776 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 1 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 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 22 ms 2276 KB Output is correct
3 Correct 14 ms 2140 KB Output is correct
4 Correct 45 ms 17500 KB Output is correct
5 Correct 33 ms 18252 KB Output is correct
6 Correct 71 ms 36176 KB Output is correct
7 Correct 20 ms 2136 KB Output is correct
8 Correct 52 ms 23760 KB Output is correct
9 Correct 45 ms 24264 KB Output is correct
10 Correct 45 ms 24264 KB Output is correct
11 Correct 50 ms 19160 KB Output is correct
12 Correct 72 ms 28160 KB Output is correct
13 Correct 47 ms 19292 KB Output is correct
14 Correct 72 ms 36284 KB Output is correct
15 Correct 68 ms 36176 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 452 KB Output is correct
21 Correct 0 ms 460 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 456 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct