# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
385156 |
2021-04-03T11:56:43 Z |
vishesh312 |
Paths (BOI18_paths) |
C++17 |
|
599 ms |
96748 KB |
#include "bits/stdc++.h"
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
*/
#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()
using ll = long long;
const int mod = 1e9+7;
vector<vector<int>> adj;
vector<vector<ll>> dp;
vector<int> c;
ll dfs(int u, int mask) {
if (dp[mask][u] != -1) return dp[mask][u];
if (mask&(1<<c[u])) return dp[mask][u] = 0;
dp[mask][u] = 1;
for (int v : adj[u]) {
dp[mask][u] += dfs(v, mask|(1<<c[u]));
}
return dp[mask][u];
}
void solve(int tc) {
int n, m, k;
cin >> n >> m >> k;
dp.resize(1<<(k+1)); adj.resize(n), c.resize(n);
for (auto &x : dp) x.resize(n, -1);
for (auto &x : c) cin >> x;
for (int i = 0; i < m; ++i) {
int u, v;
cin >> u >> v;
--u, --v;
adj[u].push_back(v);
adj[v].push_back(u);
}
ll ans = 0;
for (int i = 0; i < n; ++i) {
ans += dfs(i, 0);
}
cout << ans-n << '\n';
}
signed main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
int tc = 1;
//cin >> tc;
for (int i = 1; i <= tc; ++i) solve(i);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
7544 KB |
Output is correct |
2 |
Correct |
76 ms |
6272 KB |
Output is correct |
3 |
Correct |
456 ms |
58988 KB |
Output is correct |
4 |
Correct |
112 ms |
10852 KB |
Output is correct |
5 |
Correct |
116 ms |
9964 KB |
Output is correct |
6 |
Correct |
305 ms |
42208 KB |
Output is correct |
7 |
Correct |
445 ms |
58988 KB |
Output is correct |
8 |
Correct |
417 ms |
59784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
88 ms |
7544 KB |
Output is correct |
12 |
Correct |
76 ms |
6272 KB |
Output is correct |
13 |
Correct |
456 ms |
58988 KB |
Output is correct |
14 |
Correct |
112 ms |
10852 KB |
Output is correct |
15 |
Correct |
116 ms |
9964 KB |
Output is correct |
16 |
Correct |
305 ms |
42208 KB |
Output is correct |
17 |
Correct |
445 ms |
58988 KB |
Output is correct |
18 |
Correct |
417 ms |
59784 KB |
Output is correct |
19 |
Correct |
94 ms |
7528 KB |
Output is correct |
20 |
Correct |
79 ms |
6284 KB |
Output is correct |
21 |
Correct |
456 ms |
58988 KB |
Output is correct |
22 |
Correct |
118 ms |
10808 KB |
Output is correct |
23 |
Correct |
99 ms |
9836 KB |
Output is correct |
24 |
Correct |
299 ms |
42208 KB |
Output is correct |
25 |
Correct |
462 ms |
58988 KB |
Output is correct |
26 |
Correct |
437 ms |
59652 KB |
Output is correct |
27 |
Correct |
91 ms |
6508 KB |
Output is correct |
28 |
Correct |
128 ms |
9836 KB |
Output is correct |
29 |
Correct |
588 ms |
96492 KB |
Output is correct |
30 |
Correct |
467 ms |
51936 KB |
Output is correct |
31 |
Correct |
447 ms |
52084 KB |
Output is correct |
32 |
Correct |
599 ms |
96748 KB |
Output is correct |
33 |
Correct |
1 ms |
364 KB |
Output is correct |
34 |
Correct |
1 ms |
364 KB |
Output is correct |
35 |
Correct |
1 ms |
364 KB |
Output is correct |
36 |
Correct |
1 ms |
364 KB |
Output is correct |
37 |
Correct |
1 ms |
364 KB |
Output is correct |
38 |
Correct |
1 ms |
364 KB |
Output is correct |
39 |
Correct |
1 ms |
492 KB |
Output is correct |
40 |
Correct |
1 ms |
364 KB |
Output is correct |
41 |
Correct |
1 ms |
364 KB |
Output is correct |
42 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
43 ms |
2412 KB |
Output is correct |
3 |
Correct |
27 ms |
2284 KB |
Output is correct |
4 |
Correct |
118 ms |
19820 KB |
Output is correct |
5 |
Correct |
63 ms |
20580 KB |
Output is correct |
6 |
Correct |
220 ms |
57452 KB |
Output is correct |
7 |
Correct |
32 ms |
2304 KB |
Output is correct |
8 |
Correct |
163 ms |
32364 KB |
Output is correct |
9 |
Correct |
74 ms |
33124 KB |
Output is correct |
10 |
Correct |
132 ms |
33188 KB |
Output is correct |
11 |
Correct |
143 ms |
29800 KB |
Output is correct |
12 |
Correct |
92 ms |
44132 KB |
Output is correct |
13 |
Correct |
126 ms |
30060 KB |
Output is correct |
14 |
Correct |
213 ms |
57452 KB |
Output is correct |
15 |
Correct |
159 ms |
57580 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
364 KB |
Output is correct |
23 |
Correct |
1 ms |
364 KB |
Output is correct |
24 |
Correct |
1 ms |
364 KB |
Output is correct |
25 |
Correct |
1 ms |
364 KB |
Output is correct |