# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
319320 |
2020-11-04T17:39:46 Z |
OttoTheDino |
Paths (BOI18_paths) |
C++17 |
|
527 ms |
153364 KB |
#include <bits/stdc++.h>
using namespace std;
#define rep(n) for (int i = 0; i < n; ++i)
#define rep2(n) for (int j = 0; j < n; ++j)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<double, double> dd;
const int mxn = 5e5+5, mxa = 32;
ll dp[mxn][mxa], col[mxn];
vi neibs[mxn];
ll f (int c, int C) {
if (dp[c][C]!=-1) return dp[c][C];
ll res = C!=0, cur = C|(1<<col[c]);
for (int v : neibs[c]) if (((1<<col[v])&cur)==0) res += f (v, cur);
dp[c][C] = res;
return res;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
memset(dp, -1, mxn*mxa*sizeof(ll));
int n, m, k, a, b;
cin >> n >> m >> k;
rep (n) {
cin >> col[i];
col[i]--;
}
rep (m) {
cin >> a >> b;
neibs[a-1].pb(b-1);
neibs[b-1].pb(a-1);
}
ll ans = 0;
rep (n) ans += f(i, 0);
cout << ans << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
137324 KB |
Output is correct |
2 |
Correct |
69 ms |
137316 KB |
Output is correct |
3 |
Correct |
70 ms |
137316 KB |
Output is correct |
4 |
Correct |
70 ms |
137320 KB |
Output is correct |
5 |
Correct |
69 ms |
137316 KB |
Output is correct |
6 |
Correct |
69 ms |
137320 KB |
Output is correct |
7 |
Correct |
70 ms |
137316 KB |
Output is correct |
8 |
Correct |
69 ms |
137336 KB |
Output is correct |
9 |
Correct |
71 ms |
137316 KB |
Output is correct |
10 |
Correct |
69 ms |
137316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
150 ms |
141028 KB |
Output is correct |
2 |
Correct |
134 ms |
140900 KB |
Output is correct |
3 |
Correct |
446 ms |
148128 KB |
Output is correct |
4 |
Correct |
183 ms |
145380 KB |
Output is correct |
5 |
Correct |
181 ms |
145572 KB |
Output is correct |
6 |
Correct |
329 ms |
150256 KB |
Output is correct |
7 |
Correct |
444 ms |
152624 KB |
Output is correct |
8 |
Correct |
420 ms |
153364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
137324 KB |
Output is correct |
2 |
Correct |
69 ms |
137316 KB |
Output is correct |
3 |
Correct |
70 ms |
137316 KB |
Output is correct |
4 |
Correct |
70 ms |
137320 KB |
Output is correct |
5 |
Correct |
69 ms |
137316 KB |
Output is correct |
6 |
Correct |
69 ms |
137320 KB |
Output is correct |
7 |
Correct |
70 ms |
137316 KB |
Output is correct |
8 |
Correct |
69 ms |
137336 KB |
Output is correct |
9 |
Correct |
71 ms |
137316 KB |
Output is correct |
10 |
Correct |
69 ms |
137316 KB |
Output is correct |
11 |
Correct |
150 ms |
141028 KB |
Output is correct |
12 |
Correct |
134 ms |
140900 KB |
Output is correct |
13 |
Correct |
446 ms |
148128 KB |
Output is correct |
14 |
Correct |
183 ms |
145380 KB |
Output is correct |
15 |
Correct |
181 ms |
145572 KB |
Output is correct |
16 |
Correct |
329 ms |
150256 KB |
Output is correct |
17 |
Correct |
444 ms |
152624 KB |
Output is correct |
18 |
Correct |
420 ms |
153364 KB |
Output is correct |
19 |
Correct |
154 ms |
144100 KB |
Output is correct |
20 |
Correct |
135 ms |
143204 KB |
Output is correct |
21 |
Correct |
437 ms |
152552 KB |
Output is correct |
22 |
Correct |
190 ms |
145384 KB |
Output is correct |
23 |
Correct |
174 ms |
145380 KB |
Output is correct |
24 |
Correct |
336 ms |
150100 KB |
Output is correct |
25 |
Correct |
452 ms |
152548 KB |
Output is correct |
26 |
Correct |
422 ms |
153316 KB |
Output is correct |
27 |
Correct |
154 ms |
143332 KB |
Output is correct |
28 |
Correct |
187 ms |
144712 KB |
Output is correct |
29 |
Correct |
523 ms |
152700 KB |
Output is correct |
30 |
Correct |
422 ms |
148440 KB |
Output is correct |
31 |
Correct |
453 ms |
148440 KB |
Output is correct |
32 |
Correct |
527 ms |
152548 KB |
Output is correct |
33 |
Correct |
72 ms |
137316 KB |
Output is correct |
34 |
Correct |
70 ms |
137444 KB |
Output is correct |
35 |
Correct |
71 ms |
137316 KB |
Output is correct |
36 |
Correct |
70 ms |
137316 KB |
Output is correct |
37 |
Correct |
70 ms |
137316 KB |
Output is correct |
38 |
Correct |
69 ms |
137316 KB |
Output is correct |
39 |
Correct |
72 ms |
137444 KB |
Output is correct |
40 |
Correct |
71 ms |
137316 KB |
Output is correct |
41 |
Correct |
72 ms |
137316 KB |
Output is correct |
42 |
Correct |
69 ms |
137316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
78 ms |
137316 KB |
Output is correct |
2 |
Correct |
110 ms |
138468 KB |
Output is correct |
3 |
Correct |
93 ms |
138468 KB |
Output is correct |
4 |
Correct |
155 ms |
140900 KB |
Output is correct |
5 |
Correct |
128 ms |
141656 KB |
Output is correct |
6 |
Correct |
212 ms |
140900 KB |
Output is correct |
7 |
Correct |
98 ms |
138468 KB |
Output is correct |
8 |
Correct |
176 ms |
140900 KB |
Output is correct |
9 |
Correct |
133 ms |
141660 KB |
Output is correct |
10 |
Correct |
170 ms |
141792 KB |
Output is correct |
11 |
Correct |
167 ms |
139616 KB |
Output is correct |
12 |
Correct |
145 ms |
140892 KB |
Output is correct |
13 |
Correct |
163 ms |
139748 KB |
Output is correct |
14 |
Correct |
194 ms |
140900 KB |
Output is correct |
15 |
Correct |
172 ms |
141156 KB |
Output is correct |
16 |
Correct |
69 ms |
137316 KB |
Output is correct |
17 |
Correct |
70 ms |
137316 KB |
Output is correct |
18 |
Correct |
69 ms |
137444 KB |
Output is correct |
19 |
Correct |
69 ms |
137316 KB |
Output is correct |
20 |
Correct |
71 ms |
137316 KB |
Output is correct |
21 |
Correct |
70 ms |
137288 KB |
Output is correct |
22 |
Correct |
69 ms |
137316 KB |
Output is correct |
23 |
Correct |
70 ms |
137316 KB |
Output is correct |
24 |
Correct |
70 ms |
137316 KB |
Output is correct |
25 |
Correct |
69 ms |
137316 KB |
Output is correct |