Submission #651127

# Submission time Handle Problem Language Result Execution time Memory
651127 2022-10-17T09:58:57 Z dooompy Paths (BOI18_paths) C++17
100 / 100
956 ms 172436 KB
#include "bits/stdc++.h"

using namespace std;

void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T a, U ...b) {
    cout << a << ' ', abc(b...);
}
template <typename T> void printv(T l, T r) {
    while (l != r) cout << *l << " \n"[++l == r];
}
template <typename A, typename B> istream& operator >> (istream& o, pair<A, B> &a) {
    return o >> a.first >> a.second;
}
template <typename A, typename B> ostream& operator << (ostream& o, pair<A, B> a) {
    return o << '(' << a.first << ", " << a.second << ')';
}
template <typename T> ostream& operator << (ostream& o, vector<T> a) {
    bool is = false;
    for (T i : a) {o << (is ? ' ' : '{'), is = true, o << i;}
    return o << '}';
}

#ifdef local
#define test(args...) abc("[" + string(#args) + "]", args)
#else
#define test(args...) void(0)
#endif

using ll = long long;

int col[300005];
ll dp[300005][1 << 6];
vector<int> adj[300005];

ll total = 0;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);
    int n, m, k; cin >> n >> m >> k;
    for (int i = 1; i <= n; i++) {
        cin >> col[i];
        col[i]--; dp[i][1 << col[i]] = 1;
    }

    for (int i = 1; i <= m; i++) {
        int a, b; cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    for (int len = 2; len <= k; len++) {
        for (int i = 1; i <= n; i++) {
            int curcol = col[i];
            for (auto nxt : adj[i]) {
                for (int mask = 1; mask < (1 << 6); mask++) {
                    if (mask & (1 << curcol)) continue;
                    if (__builtin_popcount(mask) != (len - 1)) continue;
                    dp[i][mask | (1 << curcol)] += dp[nxt][mask];
                    total += dp[nxt][mask];
                }
            }

        }
    }



    cout << total;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7380 KB Output is correct
2 Correct 4 ms 7380 KB Output is correct
3 Correct 4 ms 7380 KB Output is correct
4 Correct 4 ms 7380 KB Output is correct
5 Correct 4 ms 7384 KB Output is correct
6 Correct 5 ms 7380 KB Output is correct
7 Correct 4 ms 7380 KB Output is correct
8 Correct 5 ms 7380 KB Output is correct
9 Correct 4 ms 7380 KB Output is correct
10 Correct 5 ms 7380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 286 ms 13728 KB Output is correct
2 Correct 268 ms 13520 KB Output is correct
3 Correct 652 ms 171868 KB Output is correct
4 Correct 252 ms 30300 KB Output is correct
5 Correct 92 ms 30204 KB Output is correct
6 Correct 521 ms 119432 KB Output is correct
7 Correct 630 ms 171628 KB Output is correct
8 Correct 661 ms 172348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7380 KB Output is correct
2 Correct 4 ms 7380 KB Output is correct
3 Correct 4 ms 7380 KB Output is correct
4 Correct 4 ms 7380 KB Output is correct
5 Correct 4 ms 7384 KB Output is correct
6 Correct 5 ms 7380 KB Output is correct
7 Correct 4 ms 7380 KB Output is correct
8 Correct 5 ms 7380 KB Output is correct
9 Correct 4 ms 7380 KB Output is correct
10 Correct 5 ms 7380 KB Output is correct
11 Correct 286 ms 13728 KB Output is correct
12 Correct 268 ms 13520 KB Output is correct
13 Correct 652 ms 171868 KB Output is correct
14 Correct 252 ms 30300 KB Output is correct
15 Correct 92 ms 30204 KB Output is correct
16 Correct 521 ms 119432 KB Output is correct
17 Correct 630 ms 171628 KB Output is correct
18 Correct 661 ms 172348 KB Output is correct
19 Correct 278 ms 16368 KB Output is correct
20 Correct 257 ms 13548 KB Output is correct
21 Correct 649 ms 171668 KB Output is correct
22 Correct 251 ms 30256 KB Output is correct
23 Correct 93 ms 30240 KB Output is correct
24 Correct 536 ms 119480 KB Output is correct
25 Correct 656 ms 171848 KB Output is correct
26 Correct 668 ms 172436 KB Output is correct
27 Correct 372 ms 13644 KB Output is correct
28 Correct 404 ms 18692 KB Output is correct
29 Correct 956 ms 171768 KB Output is correct
30 Correct 664 ms 92864 KB Output is correct
31 Correct 703 ms 93012 KB Output is correct
32 Correct 861 ms 171672 KB Output is correct
33 Correct 5 ms 7380 KB Output is correct
34 Correct 5 ms 7380 KB Output is correct
35 Correct 4 ms 7380 KB Output is correct
36 Correct 4 ms 7376 KB Output is correct
37 Correct 4 ms 7380 KB Output is correct
38 Correct 4 ms 7380 KB Output is correct
39 Correct 4 ms 7380 KB Output is correct
40 Correct 6 ms 7380 KB Output is correct
41 Correct 4 ms 7376 KB Output is correct
42 Correct 4 ms 7380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7380 KB Output is correct
2 Correct 161 ms 8660 KB Output is correct
3 Correct 94 ms 9468 KB Output is correct
4 Correct 214 ms 62052 KB Output is correct
5 Correct 162 ms 62712 KB Output is correct
6 Correct 325 ms 62120 KB Output is correct
7 Correct 130 ms 9372 KB Output is correct
8 Correct 339 ms 61992 KB Output is correct
9 Correct 245 ms 62700 KB Output is correct
10 Correct 313 ms 62860 KB Output is correct
11 Correct 291 ms 35528 KB Output is correct
12 Correct 321 ms 49344 KB Output is correct
13 Correct 299 ms 35788 KB Output is correct
14 Correct 416 ms 62028 KB Output is correct
15 Correct 392 ms 62284 KB Output is correct
16 Correct 5 ms 7380 KB Output is correct
17 Correct 6 ms 7380 KB Output is correct
18 Correct 5 ms 7380 KB Output is correct
19 Correct 6 ms 7380 KB Output is correct
20 Correct 5 ms 7384 KB Output is correct
21 Correct 5 ms 7380 KB Output is correct
22 Correct 5 ms 7380 KB Output is correct
23 Correct 6 ms 7380 KB Output is correct
24 Correct 6 ms 7380 KB Output is correct
25 Correct 6 ms 7372 KB Output is correct