Submission #624975

# Submission time Handle Problem Language Result Execution time Memory
624975 2022-08-09T08:30:37 Z Hanksburger Paths (BOI18_paths) C++17
100 / 100
329 ms 59960 KB
#include <bits/stdc++.h>
using namespace std;
long long dp[32][300005], a[300005];
vector<long long> adj[300005];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long n, m, p, ans=0;
    cin >> n >> m >> p;
    for (long long i=1; i<=n; i++)
    {
        cin >> a[i];
        dp[1<<(--a[i])][i]=1;
    }
    for (long long i=1; i<=m; i++)
    {
        long long u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for (long long i=1; i<(1<<p); i++)
    {
        for (long long j=1; j<=n; j++)
        {
            if (i&(1<<a[j]))
                for (long long k:adj[j])
                    dp[i][j]+=dp[i^(1<<a[j])][k];
            ans+=dp[i][j];
        }
    }
    cout << ans-n;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7508 KB Output is correct
2 Correct 4 ms 7508 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 7380 KB Output is correct
6 Correct 5 ms 7508 KB Output is correct
7 Correct 4 ms 7508 KB Output is correct
8 Correct 4 ms 7508 KB Output is correct
9 Correct 5 ms 7424 KB Output is correct
10 Correct 4 ms 7380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 17628 KB Output is correct
2 Correct 56 ms 16840 KB Output is correct
3 Correct 271 ms 41136 KB Output is correct
4 Correct 89 ms 19796 KB Output is correct
5 Correct 103 ms 19240 KB Output is correct
6 Correct 153 ms 32784 KB Output is correct
7 Correct 242 ms 41084 KB Output is correct
8 Correct 252 ms 41620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7508 KB Output is correct
2 Correct 4 ms 7508 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 7380 KB Output is correct
6 Correct 5 ms 7508 KB Output is correct
7 Correct 4 ms 7508 KB Output is correct
8 Correct 4 ms 7508 KB Output is correct
9 Correct 5 ms 7424 KB Output is correct
10 Correct 4 ms 7380 KB Output is correct
11 Correct 61 ms 17628 KB Output is correct
12 Correct 56 ms 16840 KB Output is correct
13 Correct 271 ms 41136 KB Output is correct
14 Correct 89 ms 19796 KB Output is correct
15 Correct 103 ms 19240 KB Output is correct
16 Correct 153 ms 32784 KB Output is correct
17 Correct 242 ms 41084 KB Output is correct
18 Correct 252 ms 41620 KB Output is correct
19 Correct 67 ms 17736 KB Output is correct
20 Correct 53 ms 16844 KB Output is correct
21 Correct 226 ms 41164 KB Output is correct
22 Correct 107 ms 19780 KB Output is correct
23 Correct 90 ms 19220 KB Output is correct
24 Correct 182 ms 32764 KB Output is correct
25 Correct 234 ms 41084 KB Output is correct
26 Correct 253 ms 41668 KB Output is correct
27 Correct 52 ms 16872 KB Output is correct
28 Correct 72 ms 19852 KB Output is correct
29 Correct 329 ms 59948 KB Output is correct
30 Correct 189 ms 38984 KB Output is correct
31 Correct 202 ms 37916 KB Output is correct
32 Correct 290 ms 59960 KB Output is correct
33 Correct 3 ms 7508 KB Output is correct
34 Correct 4 ms 7508 KB Output is correct
35 Correct 4 ms 7380 KB Output is correct
36 Correct 4 ms 7380 KB Output is correct
37 Correct 4 ms 7380 KB Output is correct
38 Correct 4 ms 7508 KB Output is correct
39 Correct 4 ms 7508 KB Output is correct
40 Correct 4 ms 7504 KB Output is correct
41 Correct 4 ms 7380 KB Output is correct
42 Correct 4 ms 7380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7508 KB Output is correct
2 Correct 20 ms 10580 KB Output is correct
3 Correct 25 ms 10324 KB Output is correct
4 Correct 57 ms 18476 KB Output is correct
5 Correct 44 ms 18888 KB Output is correct
6 Correct 136 ms 37444 KB Output is correct
7 Correct 26 ms 10384 KB Output is correct
8 Correct 91 ms 24768 KB Output is correct
9 Correct 70 ms 25196 KB Output is correct
10 Correct 74 ms 24140 KB Output is correct
11 Correct 82 ms 23788 KB Output is correct
12 Correct 99 ms 29032 KB Output is correct
13 Correct 64 ms 22796 KB Output is correct
14 Correct 119 ms 37456 KB Output is correct
15 Correct 106 ms 37552 KB Output is correct
16 Correct 6 ms 7508 KB Output is correct
17 Correct 4 ms 7516 KB Output is correct
18 Correct 4 ms 7380 KB Output is correct
19 Correct 4 ms 7380 KB Output is correct
20 Correct 4 ms 7380 KB Output is correct
21 Correct 4 ms 7512 KB Output is correct
22 Correct 4 ms 7508 KB Output is correct
23 Correct 4 ms 7508 KB Output is correct
24 Correct 4 ms 7380 KB Output is correct
25 Correct 4 ms 7380 KB Output is correct