Submission #869227

# Submission time Handle Problem Language Result Execution time Memory
869227 2023-11-03T14:28:39 Z sleepntsheep Paths (BOI18_paths) C++17
100 / 100
521 ms 159060 KB
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
#include <utility>
#include <array>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,tune=native")

using namespace std;
#define ALL(x) x.begin(), x.end()
#define ShinLena cin.tie(nullptr)->sync_with_stdio(false);
using ll = long long;
#define N 300005

int n, m, k, c[N];
ll d[2][N][33],z;
array<int, 2> el[N];

int main()
{
    ShinLena;
    cin >> n >> m >> k;
    for (int i = 1; i <= n; ++i) cin >> c[i], d[0][i][1<<--c[i]] = 1;
    for (int i = 0; i < m; ++i) cin >> el[i][0] >> el[i][1];
    for (int i = 1; i <= k; ++i)
    {
        for (int j = 1; j <= n; ++j) for (int s = 0; s < (1<<k); ++s) d[i&1][j][s] = 0;
        for (int j = 0; j < m; ++j)
        {
            auto [u, v] = el[j];
            for (int J = 2; J--; swap(u, v))
                for (int s = 0; s < (1<<k); ++s) 
                {
                    ll X = !((s>>c[v])&1)*d[!(i&1)][u][s];
                    d[i&1][v][s|(1<<c[v])] += X, z += X;
                }
        }
    }

    cout << z;

    return 0;
}


# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6616 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 64 ms 10884 KB Output is correct
2 Correct 53 ms 8796 KB Output is correct
3 Correct 301 ms 158804 KB Output is correct
4 Correct 57 ms 23120 KB Output is correct
5 Correct 44 ms 23184 KB Output is correct
6 Correct 198 ms 111440 KB Output is correct
7 Correct 244 ms 159060 KB Output is correct
8 Correct 345 ms 158952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6616 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 64 ms 10884 KB Output is correct
12 Correct 53 ms 8796 KB Output is correct
13 Correct 301 ms 158804 KB Output is correct
14 Correct 57 ms 23120 KB Output is correct
15 Correct 44 ms 23184 KB Output is correct
16 Correct 198 ms 111440 KB Output is correct
17 Correct 244 ms 159060 KB Output is correct
18 Correct 345 ms 158952 KB Output is correct
19 Correct 61 ms 10888 KB Output is correct
20 Correct 55 ms 9040 KB Output is correct
21 Correct 273 ms 158800 KB Output is correct
22 Correct 56 ms 23120 KB Output is correct
23 Correct 44 ms 23196 KB Output is correct
24 Correct 213 ms 111600 KB Output is correct
25 Correct 291 ms 158800 KB Output is correct
26 Correct 257 ms 158948 KB Output is correct
27 Correct 83 ms 8832 KB Output is correct
28 Correct 111 ms 12928 KB Output is correct
29 Correct 505 ms 158800 KB Output is correct
30 Correct 435 ms 84672 KB Output is correct
31 Correct 409 ms 84756 KB Output is correct
32 Correct 521 ms 158952 KB Output is correct
33 Correct 1 ms 6492 KB Output is correct
34 Correct 1 ms 6492 KB Output is correct
35 Correct 1 ms 6492 KB Output is correct
36 Correct 1 ms 6616 KB Output is correct
37 Correct 1 ms 6492 KB Output is correct
38 Correct 1 ms 6492 KB Output is correct
39 Correct 1 ms 6492 KB Output is correct
40 Correct 1 ms 6492 KB Output is correct
41 Correct 1 ms 6492 KB Output is correct
42 Correct 1 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 48 ms 8796 KB Output is correct
3 Correct 19 ms 8796 KB Output is correct
4 Correct 90 ms 59996 KB Output is correct
5 Correct 71 ms 59984 KB Output is correct
6 Correct 208 ms 60284 KB Output is correct
7 Correct 27 ms 8792 KB Output is correct
8 Correct 147 ms 60128 KB Output is correct
9 Correct 130 ms 59984 KB Output is correct
10 Correct 139 ms 60128 KB Output is correct
11 Correct 156 ms 35504 KB Output is correct
12 Correct 167 ms 47704 KB Output is correct
13 Correct 174 ms 35508 KB Output is correct
14 Correct 214 ms 59996 KB Output is correct
15 Correct 216 ms 60132 KB Output is correct
16 Correct 1 ms 6488 KB Output is correct
17 Correct 1 ms 6492 KB Output is correct
18 Correct 1 ms 6492 KB Output is correct
19 Correct 1 ms 6492 KB Output is correct
20 Correct 1 ms 6492 KB Output is correct
21 Correct 1 ms 6616 KB Output is correct
22 Correct 1 ms 6492 KB Output is correct
23 Correct 1 ms 6492 KB Output is correct
24 Correct 1 ms 6492 KB Output is correct
25 Correct 1 ms 6492 KB Output is correct