Submission #1107590

# Submission time Handle Problem Language Result Execution time Memory
1107590 2024-11-01T15:51:39 Z jadai007 Paths (BOI18_paths) C++17
100 / 100
259 ms 100424 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] += dp[i][mask^(1<<color[v])];
            }
        }
    }
    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 2 ms 10832 KB Output is correct
4 Correct 2 ms 10832 KB Output is correct
5 Correct 3 ms 10832 KB Output is correct
6 Correct 2 ms 10832 KB Output is correct
7 Correct 3 ms 10832 KB Output is correct
8 Correct 3 ms 10832 KB Output is correct
9 Correct 2 ms 11256 KB Output is correct
10 Correct 3 ms 10832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 20808 KB Output is correct
2 Correct 54 ms 20212 KB Output is correct
3 Correct 194 ms 100072 KB Output is correct
4 Correct 72 ms 27208 KB Output is correct
5 Correct 64 ms 30536 KB Output is correct
6 Correct 142 ms 73400 KB Output is correct
7 Correct 217 ms 99956 KB Output is correct
8 Correct 190 ms 100424 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 2 ms 10832 KB Output is correct
4 Correct 2 ms 10832 KB Output is correct
5 Correct 3 ms 10832 KB Output is correct
6 Correct 2 ms 10832 KB Output is correct
7 Correct 3 ms 10832 KB Output is correct
8 Correct 3 ms 10832 KB Output is correct
9 Correct 2 ms 11256 KB Output is correct
10 Correct 3 ms 10832 KB Output is correct
11 Correct 65 ms 20808 KB Output is correct
12 Correct 54 ms 20212 KB Output is correct
13 Correct 194 ms 100072 KB Output is correct
14 Correct 72 ms 27208 KB Output is correct
15 Correct 64 ms 30536 KB Output is correct
16 Correct 142 ms 73400 KB Output is correct
17 Correct 217 ms 99956 KB Output is correct
18 Correct 190 ms 100424 KB Output is correct
19 Correct 58 ms 18052 KB Output is correct
20 Correct 54 ms 20288 KB Output is correct
21 Correct 178 ms 99916 KB Output is correct
22 Correct 69 ms 30400 KB Output is correct
23 Correct 62 ms 30536 KB Output is correct
24 Correct 132 ms 73400 KB Output is correct
25 Correct 180 ms 99916 KB Output is correct
26 Correct 180 ms 100424 KB Output is correct
27 Correct 73 ms 20048 KB Output is correct
28 Correct 88 ms 24392 KB Output is correct
29 Correct 259 ms 99944 KB Output is correct
30 Correct 185 ms 57272 KB Output is correct
31 Correct 186 ms 60604 KB Output is correct
32 Correct 254 ms 99912 KB Output is correct
33 Correct 2 ms 10832 KB Output is correct
34 Correct 2 ms 10844 KB Output is correct
35 Correct 2 ms 10832 KB Output is correct
36 Correct 2 ms 10832 KB Output is correct
37 Correct 2 ms 10832 KB Output is correct
38 Correct 2 ms 10832 KB Output is correct
39 Correct 2 ms 10908 KB Output is correct
40 Correct 3 ms 10832 KB Output is correct
41 Correct 3 ms 10832 KB Output is correct
42 Correct 3 ms 11072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 10832 KB Output is correct
2 Correct 40 ms 13648 KB Output is correct
3 Correct 19 ms 12880 KB Output is correct
4 Correct 51 ms 40272 KB Output is correct
5 Correct 41 ms 40548 KB Output is correct
6 Correct 113 ms 40356 KB Output is correct
7 Correct 27 ms 13732 KB Output is correct
8 Correct 73 ms 40196 KB Output is correct
9 Correct 48 ms 40812 KB Output is correct
10 Correct 62 ms 40512 KB Output is correct
11 Correct 68 ms 25800 KB Output is correct
12 Correct 71 ms 33684 KB Output is correct
13 Correct 77 ms 26944 KB Output is correct
14 Correct 108 ms 40264 KB Output is correct
15 Correct 110 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 3 ms 10832 KB Output is correct
19 Correct 2 ms 10832 KB Output is correct
20 Correct 2 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 2 ms 10832 KB Output is correct
24 Correct 2 ms 10832 KB Output is correct
25 Correct 2 ms 10832 KB Output is correct