Submission #1107365

# Submission time Handle Problem Language Result Execution time Memory
1107365 2024-11-01T07:12:01 Z vjudge1 Paths (BOI18_paths) C++17
100 / 100
281 ms 96084 KB
#include<bits/stdc++.h>
#define int long long

using namespace std;

int n, m, k, color[300300], ans, dp[300300][32];
vector<int> vc[300300];

int32_t main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> n >> m >> k;
    for(int i = 1; i <= n; ++i) cin >> color[i], color[i]--;
    for(int i = 0; i < m; ++i){
        int u, v; cin >> u >> v;
        vc[u].push_back(v), vc[v].push_back(u);
    }
    for(int i = 1; i <= n; ++i) dp[i][(1<<color[i])] = 1;
    for(int mask = 0; mask < (1<<k); ++mask){
        for(int i = 1; i <= n; ++i){
            for(auto v:vc[i]){
                if(!(mask&(1<<color[v]))) dp[v][mask|(1<<color[v])] += dp[i][mask]; 
            }
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i) for(int j = 0; j < (1<<k); ++j) ans += dp[i][j];
    cout << ans - n;
}   
# Verdict Execution time Memory Grader output
1 Correct 2 ms 10832 KB Output is correct
2 Correct 2 ms 10832 KB Output is correct
3 Correct 3 ms 10832 KB Output is correct
4 Correct 3 ms 10832 KB Output is correct
5 Correct 3 ms 11000 KB Output is correct
6 Correct 2 ms 10832 KB Output is correct
7 Correct 2 ms 10832 KB Output is correct
8 Correct 3 ms 10832 KB Output is correct
9 Correct 2 ms 10832 KB Output is correct
10 Correct 2 ms 10832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 17960 KB Output is correct
2 Correct 47 ms 18000 KB Output is correct
3 Correct 177 ms 95480 KB Output is correct
4 Correct 68 ms 27200 KB Output is correct
5 Correct 58 ms 27208 KB Output is correct
6 Correct 130 ms 69304 KB Output is correct
7 Correct 184 ms 95524 KB Output is correct
8 Correct 178 ms 96072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 10832 KB Output is correct
2 Correct 2 ms 10832 KB Output is correct
3 Correct 3 ms 10832 KB Output is correct
4 Correct 3 ms 10832 KB Output is correct
5 Correct 3 ms 11000 KB Output is correct
6 Correct 2 ms 10832 KB Output is correct
7 Correct 2 ms 10832 KB Output is correct
8 Correct 3 ms 10832 KB Output is correct
9 Correct 2 ms 10832 KB Output is correct
10 Correct 2 ms 10832 KB Output is correct
11 Correct 63 ms 17960 KB Output is correct
12 Correct 47 ms 18000 KB Output is correct
13 Correct 177 ms 95480 KB Output is correct
14 Correct 68 ms 27200 KB Output is correct
15 Correct 58 ms 27208 KB Output is correct
16 Correct 130 ms 69304 KB Output is correct
17 Correct 184 ms 95524 KB Output is correct
18 Correct 178 ms 96072 KB Output is correct
19 Correct 62 ms 18020 KB Output is correct
20 Correct 47 ms 17824 KB Output is correct
21 Correct 182 ms 95560 KB Output is correct
22 Correct 66 ms 26992 KB Output is correct
23 Correct 58 ms 26988 KB Output is correct
24 Correct 128 ms 69304 KB Output is correct
25 Correct 172 ms 95468 KB Output is correct
26 Correct 172 ms 96084 KB Output is correct
27 Correct 76 ms 17992 KB Output is correct
28 Correct 92 ms 21476 KB Output is correct
29 Correct 277 ms 95560 KB Output is correct
30 Correct 199 ms 57272 KB Output is correct
31 Correct 222 ms 56520 KB Output is correct
32 Correct 281 ms 95560 KB Output is correct
33 Correct 2 ms 10832 KB Output is correct
34 Correct 2 ms 10832 KB Output is correct
35 Correct 2 ms 11004 KB Output is correct
36 Correct 2 ms 10832 KB Output is correct
37 Correct 3 ms 10832 KB Output is correct
38 Correct 3 ms 10832 KB Output is correct
39 Correct 3 ms 10832 KB Output is correct
40 Correct 2 ms 10832 KB Output is correct
41 Correct 3 ms 10832 KB Output is correct
42 Correct 3 ms 10860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 10832 KB Output is correct
2 Correct 39 ms 12972 KB Output is correct
3 Correct 24 ms 13052 KB Output is correct
4 Correct 59 ms 38992 KB Output is correct
5 Correct 39 ms 39364 KB Output is correct
6 Correct 113 ms 38992 KB Output is correct
7 Correct 28 ms 12892 KB Output is correct
8 Correct 73 ms 38992 KB Output is correct
9 Correct 45 ms 39364 KB Output is correct
10 Correct 69 ms 39108 KB Output is correct
11 Correct 88 ms 25612 KB Output is correct
12 Correct 79 ms 32320 KB Output is correct
13 Correct 72 ms 25920 KB Output is correct
14 Correct 120 ms 38876 KB Output is correct
15 Correct 109 ms 38984 KB Output is correct
16 Correct 2 ms 10832 KB Output is correct
17 Correct 2 ms 10832 KB Output is correct
18 Correct 2 ms 11000 KB Output is correct
19 Correct 3 ms 10832 KB Output is correct
20 Correct 3 ms 10832 KB Output is correct
21 Correct 2 ms 10832 KB Output is correct
22 Correct 2 ms 10832 KB Output is correct
23 Correct 3 ms 10832 KB Output is correct
24 Correct 2 ms 10832 KB Output is correct
25 Correct 2 ms 10832 KB Output is correct