# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
343557 | 2021-01-04T08:38:04 Z | parsabahrami | Paths (BOI18_paths) | C++17 | 451 ms | 56684 KB |
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int> pii; #define SZ(x) (int) x.size() #define F first #define S second const int N = 3e5 + 10; ll dp[40][N]; int n, m, k, C[N]; vector<int> adj[N]; int main() { scanf("%d%d%d", &n, &m, &k); for (int i = 1; i <= n; i++) scanf("%d", &C[i]), C[i]--; for (int i = 1; i <= m; i++) { int u, v; scanf("%d%d", &u, &v); adj[u].push_back(v); adj[v].push_back(u); } for (int i = 1; i <= n; i++) dp[1 << C[i]][i] = 1; for (int i = 0; i < 1 << k; i++) { for (int j = 1; j <= n; j++) { if ((i & (1 << C[j])) == 0) continue; for (int u : adj[j]) dp[i][j] += dp[i ^ (1 << C[j])][u]; } } ll res = 0; for (int i = 1; i <= n; i++) for (int j = 0; j < 1 << k; j++) res += dp[j][i]; printf("%lld\n", res - n); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 7536 KB | Output is correct |
2 | Correct | 6 ms | 7532 KB | Output is correct |
3 | Correct | 6 ms | 7408 KB | Output is correct |
4 | Correct | 6 ms | 7404 KB | Output is correct |
5 | Correct | 6 ms | 7404 KB | Output is correct |
6 | Correct | 5 ms | 7532 KB | Output is correct |
7 | Correct | 7 ms | 7532 KB | Output is correct |
8 | Correct | 5 ms | 7532 KB | Output is correct |
9 | Correct | 6 ms | 7428 KB | Output is correct |
10 | Correct | 7 ms | 7404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 101 ms | 14148 KB | Output is correct |
2 | Correct | 75 ms | 13292 KB | Output is correct |
3 | Correct | 372 ms | 37956 KB | Output is correct |
4 | Correct | 142 ms | 15960 KB | Output is correct |
5 | Correct | 155 ms | 15468 KB | Output is correct |
6 | Correct | 257 ms | 30508 KB | Output is correct |
7 | Correct | 363 ms | 38028 KB | Output is correct |
8 | Correct | 358 ms | 38508 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 7536 KB | Output is correct |
2 | Correct | 6 ms | 7532 KB | Output is correct |
3 | Correct | 6 ms | 7408 KB | Output is correct |
4 | Correct | 6 ms | 7404 KB | Output is correct |
5 | Correct | 6 ms | 7404 KB | Output is correct |
6 | Correct | 5 ms | 7532 KB | Output is correct |
7 | Correct | 7 ms | 7532 KB | Output is correct |
8 | Correct | 5 ms | 7532 KB | Output is correct |
9 | Correct | 6 ms | 7428 KB | Output is correct |
10 | Correct | 7 ms | 7404 KB | Output is correct |
11 | Correct | 101 ms | 14148 KB | Output is correct |
12 | Correct | 75 ms | 13292 KB | Output is correct |
13 | Correct | 372 ms | 37956 KB | Output is correct |
14 | Correct | 142 ms | 15960 KB | Output is correct |
15 | Correct | 155 ms | 15468 KB | Output is correct |
16 | Correct | 257 ms | 30508 KB | Output is correct |
17 | Correct | 363 ms | 38028 KB | Output is correct |
18 | Correct | 358 ms | 38508 KB | Output is correct |
19 | Correct | 101 ms | 14180 KB | Output is correct |
20 | Correct | 75 ms | 13328 KB | Output is correct |
21 | Correct | 359 ms | 37896 KB | Output is correct |
22 | Correct | 129 ms | 15980 KB | Output is correct |
23 | Correct | 124 ms | 15468 KB | Output is correct |
24 | Correct | 238 ms | 30304 KB | Output is correct |
25 | Correct | 344 ms | 37996 KB | Output is correct |
26 | Correct | 356 ms | 38508 KB | Output is correct |
27 | Correct | 75 ms | 13420 KB | Output is correct |
28 | Correct | 101 ms | 15744 KB | Output is correct |
29 | Correct | 451 ms | 56684 KB | Output is correct |
30 | Correct | 285 ms | 35552 KB | Output is correct |
31 | Correct | 308 ms | 34356 KB | Output is correct |
32 | Correct | 449 ms | 56684 KB | Output is correct |
33 | Correct | 5 ms | 7532 KB | Output is correct |
34 | Correct | 5 ms | 7532 KB | Output is correct |
35 | Correct | 5 ms | 7404 KB | Output is correct |
36 | Correct | 5 ms | 7404 KB | Output is correct |
37 | Correct | 6 ms | 7404 KB | Output is correct |
38 | Correct | 5 ms | 7532 KB | Output is correct |
39 | Correct | 5 ms | 7532 KB | Output is correct |
40 | Correct | 6 ms | 7532 KB | Output is correct |
41 | Correct | 6 ms | 7532 KB | Output is correct |
42 | Correct | 5 ms | 7404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 7532 KB | Output is correct |
2 | Correct | 30 ms | 9580 KB | Output is correct |
3 | Correct | 28 ms | 9324 KB | Output is correct |
4 | Correct | 85 ms | 17532 KB | Output is correct |
5 | Correct | 70 ms | 18148 KB | Output is correct |
6 | Correct | 174 ms | 36460 KB | Output is correct |
7 | Correct | 30 ms | 9472 KB | Output is correct |
8 | Correct | 129 ms | 23916 KB | Output is correct |
9 | Correct | 101 ms | 24580 KB | Output is correct |
10 | Correct | 98 ms | 23660 KB | Output is correct |
11 | Correct | 86 ms | 22888 KB | Output is correct |
12 | Correct | 93 ms | 28388 KB | Output is correct |
13 | Correct | 85 ms | 21988 KB | Output is correct |
14 | Correct | 176 ms | 36484 KB | Output is correct |
15 | Correct | 170 ms | 36460 KB | Output is correct |
16 | Correct | 5 ms | 7532 KB | Output is correct |
17 | Correct | 6 ms | 7532 KB | Output is correct |
18 | Correct | 5 ms | 7404 KB | Output is correct |
19 | Correct | 7 ms | 7404 KB | Output is correct |
20 | Correct | 8 ms | 7404 KB | Output is correct |
21 | Correct | 5 ms | 7532 KB | Output is correct |
22 | Correct | 5 ms | 7532 KB | Output is correct |
23 | Correct | 5 ms | 7532 KB | Output is correct |
24 | Correct | 5 ms | 7532 KB | Output is correct |
25 | Correct | 5 ms | 7404 KB | Output is correct |