답안 #721997

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
721997 2023-04-11T10:08:22 Z Jarif_Rahman Paths (BOI18_paths) C++17
100 / 100
386 ms 70636 KB
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, m, k; cin >> n >> m >> k;
    vector<int> color(n);
    for(int &x: color) cin >> x, x--;
    vector<vector<int>> graph(n);
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b; a--, b--;
        graph[a].pb(b);
        graph[b].pb(a);
    }

    vector<vector<ll>> dp(n, vector<ll>((1<<k), 0));
    for(int i = 0; i < n; i++) dp[i][1<<color[i]] = 1;

    for(int i = 0; i < (1<<k); i++){
        if(__builtin_popcount(i) < 2) continue;
        for(int j = 0; j < n; j++) if(i&(1<<color[j])){
            for(int x: graph[j]) dp[j][i]+=dp[x][i^(1<<color[j])];
        }
    }

    ll ans = 0;
    for(int i = 0; i < (1<<k); i++) if(__builtin_popcount(i) > 1)
        for(int j = 0; j < n; j++) ans+=dp[j][i];
    cout << ans << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 6928 KB Output is correct
2 Correct 45 ms 6220 KB Output is correct
3 Correct 265 ms 52100 KB Output is correct
4 Correct 91 ms 10572 KB Output is correct
5 Correct 78 ms 10012 KB Output is correct
6 Correct 202 ms 37336 KB Output is correct
7 Correct 276 ms 52024 KB Output is correct
8 Correct 279 ms 52480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 55 ms 6928 KB Output is correct
12 Correct 45 ms 6220 KB Output is correct
13 Correct 265 ms 52100 KB Output is correct
14 Correct 91 ms 10572 KB Output is correct
15 Correct 78 ms 10012 KB Output is correct
16 Correct 202 ms 37336 KB Output is correct
17 Correct 276 ms 52024 KB Output is correct
18 Correct 279 ms 52480 KB Output is correct
19 Correct 58 ms 6972 KB Output is correct
20 Correct 46 ms 6096 KB Output is correct
21 Correct 262 ms 51796 KB Output is correct
22 Correct 101 ms 10608 KB Output is correct
23 Correct 74 ms 10080 KB Output is correct
24 Correct 206 ms 37280 KB Output is correct
25 Correct 258 ms 51904 KB Output is correct
26 Correct 248 ms 52556 KB Output is correct
27 Correct 47 ms 6220 KB Output is correct
28 Correct 73 ms 8680 KB Output is correct
29 Correct 377 ms 70592 KB Output is correct
30 Correct 252 ms 38976 KB Output is correct
31 Correct 260 ms 38868 KB Output is correct
32 Correct 386 ms 70636 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 0 ms 340 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 17 ms 2188 KB Output is correct
3 Correct 18 ms 2088 KB Output is correct
4 Correct 60 ms 17260 KB Output is correct
5 Correct 55 ms 18132 KB Output is correct
6 Correct 167 ms 36044 KB Output is correct
7 Correct 16 ms 2128 KB Output is correct
8 Correct 121 ms 23624 KB Output is correct
9 Correct 75 ms 24376 KB Output is correct
10 Correct 100 ms 24248 KB Output is correct
11 Correct 91 ms 19052 KB Output is correct
12 Correct 106 ms 28012 KB Output is correct
13 Correct 86 ms 19128 KB Output is correct
14 Correct 171 ms 36152 KB Output is correct
15 Correct 161 ms 36260 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 324 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct