# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
85938 |
2018-11-23T06:20:16 Z |
shoemakerjo |
Paths (BOI18_paths) |
C++14 |
|
528 ms |
173540 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 300010
ll dp[maxn][32];
ll ans = 0LL;
vector<int> adj[maxn];
int N, M, K;
int col[maxn];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> N >> M >> K;
for (int i = 1; i <= N; i++) {
cin >> col[i];
col[i]--;
}
int a, b;
for (int i = 0; i < M; i++) {
cin >> a >> b;
adj[a].push_back(b);
adj[b].push_back(a);
}
for (int mask = 0; mask < (1 << K); mask++) {
// cout << "on mask: " << mask << endl;
for (int i = 1; i <= N; i++) {
if ( (mask & (1 << col[i])) == 0 )
continue;
int gm = mask - ( 1 << col[i]);
if (gm == 0) {
dp[i][mask] = 1;
}
else {
for (int v : adj[i]) {
dp[i][mask] += dp[v][gm];
}
}
ans += dp[i][mask];
}
}
cout << ans-N << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
7544 KB |
Output is correct |
2 |
Correct |
8 ms |
7664 KB |
Output is correct |
3 |
Correct |
8 ms |
7664 KB |
Output is correct |
4 |
Correct |
9 ms |
7836 KB |
Output is correct |
5 |
Correct |
8 ms |
7928 KB |
Output is correct |
6 |
Correct |
9 ms |
7928 KB |
Output is correct |
7 |
Correct |
8 ms |
7928 KB |
Output is correct |
8 |
Correct |
8 ms |
7928 KB |
Output is correct |
9 |
Correct |
8 ms |
7928 KB |
Output is correct |
10 |
Correct |
8 ms |
7928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
15608 KB |
Output is correct |
2 |
Correct |
74 ms |
16644 KB |
Output is correct |
3 |
Correct |
412 ms |
102280 KB |
Output is correct |
4 |
Correct |
120 ms |
102280 KB |
Output is correct |
5 |
Correct |
152 ms |
102280 KB |
Output is correct |
6 |
Correct |
272 ms |
102280 KB |
Output is correct |
7 |
Correct |
407 ms |
117520 KB |
Output is correct |
8 |
Correct |
482 ms |
122616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
7544 KB |
Output is correct |
2 |
Correct |
8 ms |
7664 KB |
Output is correct |
3 |
Correct |
8 ms |
7664 KB |
Output is correct |
4 |
Correct |
9 ms |
7836 KB |
Output is correct |
5 |
Correct |
8 ms |
7928 KB |
Output is correct |
6 |
Correct |
9 ms |
7928 KB |
Output is correct |
7 |
Correct |
8 ms |
7928 KB |
Output is correct |
8 |
Correct |
8 ms |
7928 KB |
Output is correct |
9 |
Correct |
8 ms |
7928 KB |
Output is correct |
10 |
Correct |
8 ms |
7928 KB |
Output is correct |
11 |
Correct |
95 ms |
15608 KB |
Output is correct |
12 |
Correct |
74 ms |
16644 KB |
Output is correct |
13 |
Correct |
412 ms |
102280 KB |
Output is correct |
14 |
Correct |
120 ms |
102280 KB |
Output is correct |
15 |
Correct |
152 ms |
102280 KB |
Output is correct |
16 |
Correct |
272 ms |
102280 KB |
Output is correct |
17 |
Correct |
407 ms |
117520 KB |
Output is correct |
18 |
Correct |
482 ms |
122616 KB |
Output is correct |
19 |
Correct |
106 ms |
122616 KB |
Output is correct |
20 |
Correct |
73 ms |
122616 KB |
Output is correct |
21 |
Correct |
389 ms |
131576 KB |
Output is correct |
22 |
Correct |
154 ms |
131576 KB |
Output is correct |
23 |
Correct |
152 ms |
131576 KB |
Output is correct |
24 |
Correct |
343 ms |
131576 KB |
Output is correct |
25 |
Correct |
406 ms |
146900 KB |
Output is correct |
26 |
Correct |
448 ms |
151984 KB |
Output is correct |
27 |
Correct |
82 ms |
151984 KB |
Output is correct |
28 |
Correct |
124 ms |
151984 KB |
Output is correct |
29 |
Correct |
528 ms |
160956 KB |
Output is correct |
30 |
Correct |
317 ms |
160956 KB |
Output is correct |
31 |
Correct |
346 ms |
160956 KB |
Output is correct |
32 |
Correct |
515 ms |
173540 KB |
Output is correct |
33 |
Correct |
8 ms |
173540 KB |
Output is correct |
34 |
Correct |
9 ms |
173540 KB |
Output is correct |
35 |
Correct |
9 ms |
173540 KB |
Output is correct |
36 |
Correct |
8 ms |
173540 KB |
Output is correct |
37 |
Correct |
8 ms |
173540 KB |
Output is correct |
38 |
Correct |
8 ms |
173540 KB |
Output is correct |
39 |
Correct |
8 ms |
173540 KB |
Output is correct |
40 |
Correct |
10 ms |
173540 KB |
Output is correct |
41 |
Correct |
8 ms |
173540 KB |
Output is correct |
42 |
Correct |
9 ms |
173540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
173540 KB |
Output is correct |
2 |
Correct |
33 ms |
173540 KB |
Output is correct |
3 |
Correct |
37 ms |
173540 KB |
Output is correct |
4 |
Correct |
103 ms |
173540 KB |
Output is correct |
5 |
Correct |
88 ms |
173540 KB |
Output is correct |
6 |
Correct |
192 ms |
173540 KB |
Output is correct |
7 |
Correct |
34 ms |
173540 KB |
Output is correct |
8 |
Correct |
116 ms |
173540 KB |
Output is correct |
9 |
Correct |
109 ms |
173540 KB |
Output is correct |
10 |
Correct |
121 ms |
173540 KB |
Output is correct |
11 |
Correct |
111 ms |
173540 KB |
Output is correct |
12 |
Correct |
122 ms |
173540 KB |
Output is correct |
13 |
Correct |
93 ms |
173540 KB |
Output is correct |
14 |
Correct |
197 ms |
173540 KB |
Output is correct |
15 |
Correct |
203 ms |
173540 KB |
Output is correct |
16 |
Correct |
8 ms |
173540 KB |
Output is correct |
17 |
Correct |
8 ms |
173540 KB |
Output is correct |
18 |
Correct |
8 ms |
173540 KB |
Output is correct |
19 |
Correct |
8 ms |
173540 KB |
Output is correct |
20 |
Correct |
9 ms |
173540 KB |
Output is correct |
21 |
Correct |
8 ms |
173540 KB |
Output is correct |
22 |
Correct |
10 ms |
173540 KB |
Output is correct |
23 |
Correct |
8 ms |
173540 KB |
Output is correct |
24 |
Correct |
8 ms |
173540 KB |
Output is correct |
25 |
Correct |
8 ms |
173540 KB |
Output is correct |