# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
823368 |
2023-08-12T11:59:22 Z |
Desh03 |
Paths (BOI18_paths) |
C++17 |
|
346 ms |
58976 KB |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m, k;
cin >> n >> m >> k;
vector<int> c(n);
vector<vector<int>> g(n);
vector f(1 << k, vector<long long> (n));
for (int i = 0; i < n; i++) {
cin >> c[i];
--c[i];
++f[1 << c[i]][i];
}
for (int i = 0; i < m; i++) {
int u, v;
cin >> u >> v;
--u, --v;
g[u].push_back(v);
g[v].push_back(u);
}
long long ans = 0;
for (int i = 0; i < (1 << k); i++) {
for (int u = 0; u < n; u++) {
for (int v : g[u]) {
if (i >> c[v] & 1 ^ 1) {
f[i | (1 << c[v])][v] += f[i][u];
}
}
ans += f[i][u];
}
}
cout << ans - n << '\n';
return 0;
}
Compilation message
paths.cpp: In function 'int main()':
paths.cpp:29:31: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
29 | if (i >> c[v] & 1 ^ 1) {
| ~~~~~~~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
320 KB |
Output is correct |
8 |
Correct |
0 ms |
316 KB |
Output is correct |
9 |
Correct |
0 ms |
320 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
7152 KB |
Output is correct |
2 |
Correct |
49 ms |
6224 KB |
Output is correct |
3 |
Correct |
225 ms |
40112 KB |
Output is correct |
4 |
Correct |
71 ms |
9760 KB |
Output is correct |
5 |
Correct |
58 ms |
9240 KB |
Output is correct |
6 |
Correct |
150 ms |
29460 KB |
Output is correct |
7 |
Correct |
198 ms |
40176 KB |
Output is correct |
8 |
Correct |
296 ms |
40832 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
320 KB |
Output is correct |
8 |
Correct |
0 ms |
316 KB |
Output is correct |
9 |
Correct |
0 ms |
320 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
59 ms |
7152 KB |
Output is correct |
12 |
Correct |
49 ms |
6224 KB |
Output is correct |
13 |
Correct |
225 ms |
40112 KB |
Output is correct |
14 |
Correct |
71 ms |
9760 KB |
Output is correct |
15 |
Correct |
58 ms |
9240 KB |
Output is correct |
16 |
Correct |
150 ms |
29460 KB |
Output is correct |
17 |
Correct |
198 ms |
40176 KB |
Output is correct |
18 |
Correct |
296 ms |
40832 KB |
Output is correct |
19 |
Correct |
60 ms |
7224 KB |
Output is correct |
20 |
Correct |
48 ms |
6224 KB |
Output is correct |
21 |
Correct |
264 ms |
40092 KB |
Output is correct |
22 |
Correct |
67 ms |
9828 KB |
Output is correct |
23 |
Correct |
59 ms |
9284 KB |
Output is correct |
24 |
Correct |
155 ms |
29536 KB |
Output is correct |
25 |
Correct |
273 ms |
40176 KB |
Output is correct |
26 |
Correct |
219 ms |
40880 KB |
Output is correct |
27 |
Correct |
70 ms |
6216 KB |
Output is correct |
28 |
Correct |
93 ms |
8812 KB |
Output is correct |
29 |
Correct |
329 ms |
58892 KB |
Output is correct |
30 |
Correct |
182 ms |
33208 KB |
Output is correct |
31 |
Correct |
272 ms |
33076 KB |
Output is correct |
32 |
Correct |
346 ms |
58976 KB |
Output is correct |
33 |
Correct |
1 ms |
212 KB |
Output is correct |
34 |
Correct |
1 ms |
340 KB |
Output is correct |
35 |
Correct |
0 ms |
212 KB |
Output is correct |
36 |
Correct |
1 ms |
212 KB |
Output is correct |
37 |
Correct |
0 ms |
212 KB |
Output is correct |
38 |
Correct |
1 ms |
340 KB |
Output is correct |
39 |
Correct |
0 ms |
212 KB |
Output is correct |
40 |
Correct |
1 ms |
340 KB |
Output is correct |
41 |
Correct |
0 ms |
212 KB |
Output is correct |
42 |
Correct |
1 ms |
312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
37 ms |
2300 KB |
Output is correct |
3 |
Correct |
16 ms |
2124 KB |
Output is correct |
4 |
Correct |
51 ms |
13380 KB |
Output is correct |
5 |
Correct |
38 ms |
14204 KB |
Output is correct |
6 |
Correct |
115 ms |
32332 KB |
Output is correct |
7 |
Correct |
25 ms |
2132 KB |
Output is correct |
8 |
Correct |
70 ms |
19764 KB |
Output is correct |
9 |
Correct |
54 ms |
20436 KB |
Output is correct |
10 |
Correct |
76 ms |
20576 KB |
Output is correct |
11 |
Correct |
75 ms |
17196 KB |
Output is correct |
12 |
Correct |
71 ms |
25196 KB |
Output is correct |
13 |
Correct |
76 ms |
17476 KB |
Output is correct |
14 |
Correct |
116 ms |
32228 KB |
Output is correct |
15 |
Correct |
116 ms |
32424 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
0 ms |
316 KB |
Output is correct |
24 |
Correct |
0 ms |
212 KB |
Output is correct |
25 |
Correct |
0 ms |
212 KB |
Output is correct |