답안 #1006117

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1006117 2024-06-23T12:26:29 Z pudelos Paths (BOI18_paths) C++17
100 / 100
217 ms 92816 KB
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=a; i<=b; ++i)
#define eb emplace_back
#define ll long long
#define V vector
const int maxn=3e5+7, maxk=5;

ll dp[maxn][1<<maxk];
int n, m, k;
V<int> A;
V<V<int>> con;

int main() {
  cin.tie(0) -> ios_base::sync_with_stdio(0);
  cin >> n >> m >> k;
  A.resize(n+1);
  con.resize(n+1);
  FOR(i, 1, n) {
    cin >> A[i];
    --A[i];
    dp[i][1<<A[i]]=1;
  }
  int a, b;
  FOR(i, 1, m) {
    cin >> a >> b;
    con[a].eb(b);
    con[b].eb(a);
  }

  ll odp=0;
  FOR(m, 1, (1<<k)-1) {
    FOR(v, 1, n) {
      int gr = A[v];
      if((m|(1<<gr))!=m) continue;
      if(__builtin_popcount(m)>=2) odp+=dp[v][m];
      for(int u : con[v]) {
        int sgr = A[u];
        if((m|(1<<sgr))==m) continue;
        dp[u][m|(1<<sgr)]+=dp[v][m];
      }
    }
  }
  cout << odp << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 6344 KB Output is correct
2 Correct 45 ms 6236 KB Output is correct
3 Correct 163 ms 91988 KB Output is correct
4 Correct 54 ms 13908 KB Output is correct
5 Correct 51 ms 13840 KB Output is correct
6 Correct 119 ms 64408 KB Output is correct
7 Correct 148 ms 91984 KB Output is correct
8 Correct 149 ms 92760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 46 ms 6344 KB Output is correct
12 Correct 45 ms 6236 KB Output is correct
13 Correct 163 ms 91988 KB Output is correct
14 Correct 54 ms 13908 KB Output is correct
15 Correct 51 ms 13840 KB Output is correct
16 Correct 119 ms 64408 KB Output is correct
17 Correct 148 ms 91984 KB Output is correct
18 Correct 149 ms 92760 KB Output is correct
19 Correct 44 ms 6488 KB Output is correct
20 Correct 38 ms 6224 KB Output is correct
21 Correct 149 ms 92000 KB Output is correct
22 Correct 54 ms 13904 KB Output is correct
23 Correct 61 ms 13952 KB Output is correct
24 Correct 110 ms 64424 KB Output is correct
25 Correct 164 ms 92168 KB Output is correct
26 Correct 143 ms 92816 KB Output is correct
27 Correct 45 ms 6236 KB Output is correct
28 Correct 62 ms 7292 KB Output is correct
29 Correct 217 ms 91988 KB Output is correct
30 Correct 134 ms 49468 KB Output is correct
31 Correct 130 ms 49668 KB Output is correct
32 Correct 207 ms 91984 KB Output is correct
33 Correct 1 ms 592 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 348 KB Output is correct
37 Correct 0 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 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 23 ms 1628 KB Output is correct
3 Correct 12 ms 1628 KB Output is correct
4 Correct 40 ms 32860 KB Output is correct
5 Correct 36 ms 33372 KB Output is correct
6 Correct 107 ms 32636 KB Output is correct
7 Correct 20 ms 1628 KB Output is correct
8 Correct 56 ms 32596 KB Output is correct
9 Correct 41 ms 33492 KB Output is correct
10 Correct 47 ms 33496 KB Output is correct
11 Correct 48 ms 18132 KB Output is correct
12 Correct 60 ms 25932 KB Output is correct
13 Correct 49 ms 18388 KB Output is correct
14 Correct 84 ms 32648 KB Output is correct
15 Correct 83 ms 32852 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 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 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 1 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct