Submission #166025

# Submission time Handle Problem Language Result Execution time Memory
166025 2019-11-30T09:24:55 Z dolphingarlic Paths (BOI18_paths) C++14
100 / 100
477 ms 56824 KB
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;

ll ans = 0, dp[32][300001];
int colour[300001];
vector<int> graph[300001];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    FOR(i, 1, n + 1) {
        int x;
        cin >> x;
        colour[i] = (1<<(x - 1));
        dp[colour[i]][i] = 1;
    }
    FOR(i, 0, m) {
        int a, b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    FOR(i, 1, (1<<k)) {
        FOR(j, 1, n + 1) {
            if (colour[j] & i) {
                for (int k : graph[j]) {
                    if (colour[k] & (i - colour[j])) {
                        ans += dp[i - colour[j]][k];
                        dp[i][j] += dp[i - colour[j]][k];
                    }
                }
            }
        }
    }

    cout << ans << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7544 KB Output is correct
2 Correct 10 ms 7544 KB Output is correct
3 Correct 8 ms 7416 KB Output is correct
4 Correct 8 ms 7416 KB Output is correct
5 Correct 8 ms 7420 KB Output is correct
6 Correct 26 ms 7544 KB Output is correct
7 Correct 8 ms 7544 KB Output is correct
8 Correct 8 ms 7544 KB Output is correct
9 Correct 8 ms 7544 KB Output is correct
10 Correct 9 ms 7416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 105 ms 14188 KB Output is correct
2 Correct 83 ms 13448 KB Output is correct
3 Correct 323 ms 37880 KB Output is correct
4 Correct 138 ms 16120 KB Output is correct
5 Correct 138 ms 15584 KB Output is correct
6 Correct 243 ms 30416 KB Output is correct
7 Correct 361 ms 38008 KB Output is correct
8 Correct 384 ms 38648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7544 KB Output is correct
2 Correct 10 ms 7544 KB Output is correct
3 Correct 8 ms 7416 KB Output is correct
4 Correct 8 ms 7416 KB Output is correct
5 Correct 8 ms 7420 KB Output is correct
6 Correct 26 ms 7544 KB Output is correct
7 Correct 8 ms 7544 KB Output is correct
8 Correct 8 ms 7544 KB Output is correct
9 Correct 8 ms 7544 KB Output is correct
10 Correct 9 ms 7416 KB Output is correct
11 Correct 105 ms 14188 KB Output is correct
12 Correct 83 ms 13448 KB Output is correct
13 Correct 323 ms 37880 KB Output is correct
14 Correct 138 ms 16120 KB Output is correct
15 Correct 138 ms 15584 KB Output is correct
16 Correct 243 ms 30416 KB Output is correct
17 Correct 361 ms 38008 KB Output is correct
18 Correct 384 ms 38648 KB Output is correct
19 Correct 106 ms 14172 KB Output is correct
20 Correct 84 ms 13304 KB Output is correct
21 Correct 360 ms 37880 KB Output is correct
22 Correct 151 ms 16120 KB Output is correct
23 Correct 140 ms 15608 KB Output is correct
24 Correct 258 ms 30444 KB Output is correct
25 Correct 349 ms 37972 KB Output is correct
26 Correct 335 ms 38664 KB Output is correct
27 Correct 99 ms 13304 KB Output is correct
28 Correct 128 ms 15740 KB Output is correct
29 Correct 477 ms 56824 KB Output is correct
30 Correct 300 ms 35688 KB Output is correct
31 Correct 304 ms 33232 KB Output is correct
32 Correct 463 ms 56704 KB Output is correct
33 Correct 9 ms 7544 KB Output is correct
34 Correct 8 ms 7544 KB Output is correct
35 Correct 8 ms 7416 KB Output is correct
36 Correct 10 ms 7416 KB Output is correct
37 Correct 9 ms 7416 KB Output is correct
38 Correct 9 ms 7516 KB Output is correct
39 Correct 8 ms 7544 KB Output is correct
40 Correct 9 ms 7544 KB Output is correct
41 Correct 8 ms 7416 KB Output is correct
42 Correct 9 ms 7416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 7544 KB Output is correct
2 Correct 48 ms 9592 KB Output is correct
3 Correct 33 ms 9308 KB Output is correct
4 Correct 91 ms 17532 KB Output is correct
5 Correct 71 ms 17392 KB Output is correct
6 Correct 169 ms 36652 KB Output is correct
7 Correct 51 ms 9464 KB Output is correct
8 Correct 116 ms 23776 KB Output is correct
9 Correct 87 ms 21536 KB Output is correct
10 Correct 94 ms 21280 KB Output is correct
11 Correct 103 ms 23032 KB Output is correct
12 Correct 98 ms 24944 KB Output is correct
13 Correct 99 ms 21104 KB Output is correct
14 Correct 169 ms 36340 KB Output is correct
15 Correct 170 ms 36600 KB Output is correct
16 Correct 9 ms 7544 KB Output is correct
17 Correct 8 ms 7544 KB Output is correct
18 Correct 9 ms 7416 KB Output is correct
19 Correct 8 ms 7492 KB Output is correct
20 Correct 8 ms 7416 KB Output is correct
21 Correct 9 ms 7544 KB Output is correct
22 Correct 8 ms 7544 KB Output is correct
23 Correct 8 ms 7544 KB Output is correct
24 Correct 8 ms 7420 KB Output is correct
25 Correct 8 ms 7416 KB Output is correct