# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
825436 |
2023-08-14T20:13:16 Z |
QwertyPi |
Paths (BOI18_paths) |
C++14 |
|
737 ms |
100424 KB |
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MAXN = 3e5 + 11;
int a[MAXN];
int dp[MAXN][1 << 5];
vector<int> G[MAXN];
struct edge{
int u, v;
};
vector<edge> E;
int32_t main(){
int n, m, k; cin >> n >> m >> k;
for(int i = 0; i < n; i++) cin >> a[i];
for(int i = 0; i < n; i++) a[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);
}
for(int i = 0; i < n; i++){
dp[i][1 << a[i]] = 1;
}
for(int mask = 0; mask < (1 << k); mask++){
for(int j = 0; j < k; j++){
if((1 << j) & mask){
for(int i = 0; i < n; i++){
for(auto u : G[i]){
if(a[u] != j) continue;
dp[u][mask] += dp[i][mask - (1 << j)];
}
}
}
}
}
int ans = 0;
for(int i = 0; i < n; i++){
for(int j = 0; j < (1 << k); j++){
ans += dp[i][j];
}
}
cout << ans - n << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
7252 KB |
Output is correct |
2 |
Correct |
3 ms |
7380 KB |
Output is correct |
3 |
Correct |
3 ms |
7380 KB |
Output is correct |
4 |
Correct |
3 ms |
7380 KB |
Output is correct |
5 |
Correct |
3 ms |
7380 KB |
Output is correct |
6 |
Correct |
3 ms |
7364 KB |
Output is correct |
7 |
Correct |
3 ms |
7380 KB |
Output is correct |
8 |
Correct |
3 ms |
7380 KB |
Output is correct |
9 |
Correct |
3 ms |
7252 KB |
Output is correct |
10 |
Correct |
3 ms |
7252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
147 ms |
15820 KB |
Output is correct |
2 |
Correct |
118 ms |
14660 KB |
Output is correct |
3 |
Correct |
429 ms |
99464 KB |
Output is correct |
4 |
Correct |
177 ms |
26544 KB |
Output is correct |
5 |
Correct |
147 ms |
26512 KB |
Output is correct |
6 |
Correct |
310 ms |
71976 KB |
Output is correct |
7 |
Correct |
522 ms |
99836 KB |
Output is correct |
8 |
Correct |
432 ms |
100424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
7252 KB |
Output is correct |
2 |
Correct |
3 ms |
7380 KB |
Output is correct |
3 |
Correct |
3 ms |
7380 KB |
Output is correct |
4 |
Correct |
3 ms |
7380 KB |
Output is correct |
5 |
Correct |
3 ms |
7380 KB |
Output is correct |
6 |
Correct |
3 ms |
7364 KB |
Output is correct |
7 |
Correct |
3 ms |
7380 KB |
Output is correct |
8 |
Correct |
3 ms |
7380 KB |
Output is correct |
9 |
Correct |
3 ms |
7252 KB |
Output is correct |
10 |
Correct |
3 ms |
7252 KB |
Output is correct |
11 |
Correct |
147 ms |
15820 KB |
Output is correct |
12 |
Correct |
118 ms |
14660 KB |
Output is correct |
13 |
Correct |
429 ms |
99464 KB |
Output is correct |
14 |
Correct |
177 ms |
26544 KB |
Output is correct |
15 |
Correct |
147 ms |
26512 KB |
Output is correct |
16 |
Correct |
310 ms |
71976 KB |
Output is correct |
17 |
Correct |
522 ms |
99836 KB |
Output is correct |
18 |
Correct |
432 ms |
100424 KB |
Output is correct |
19 |
Correct |
145 ms |
18672 KB |
Output is correct |
20 |
Correct |
148 ms |
16956 KB |
Output is correct |
21 |
Correct |
447 ms |
99824 KB |
Output is correct |
22 |
Correct |
164 ms |
26532 KB |
Output is correct |
23 |
Correct |
190 ms |
26556 KB |
Output is correct |
24 |
Correct |
304 ms |
71972 KB |
Output is correct |
25 |
Correct |
445 ms |
99836 KB |
Output is correct |
26 |
Correct |
406 ms |
100352 KB |
Output is correct |
27 |
Correct |
170 ms |
16836 KB |
Output is correct |
28 |
Correct |
192 ms |
20816 KB |
Output is correct |
29 |
Correct |
737 ms |
99840 KB |
Output is correct |
30 |
Correct |
468 ms |
58848 KB |
Output is correct |
31 |
Correct |
502 ms |
58948 KB |
Output is correct |
32 |
Correct |
700 ms |
99856 KB |
Output is correct |
33 |
Correct |
3 ms |
7360 KB |
Output is correct |
34 |
Correct |
4 ms |
7380 KB |
Output is correct |
35 |
Correct |
3 ms |
7352 KB |
Output is correct |
36 |
Correct |
4 ms |
7352 KB |
Output is correct |
37 |
Correct |
3 ms |
7348 KB |
Output is correct |
38 |
Correct |
4 ms |
7380 KB |
Output is correct |
39 |
Correct |
4 ms |
7380 KB |
Output is correct |
40 |
Correct |
4 ms |
7380 KB |
Output is correct |
41 |
Correct |
3 ms |
7252 KB |
Output is correct |
42 |
Correct |
3 ms |
7252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7252 KB |
Output is correct |
2 |
Correct |
73 ms |
9628 KB |
Output is correct |
3 |
Correct |
43 ms |
9596 KB |
Output is correct |
4 |
Correct |
124 ms |
36648 KB |
Output is correct |
5 |
Correct |
95 ms |
37088 KB |
Output is correct |
6 |
Correct |
333 ms |
36692 KB |
Output is correct |
7 |
Correct |
56 ms |
9676 KB |
Output is correct |
8 |
Correct |
216 ms |
36640 KB |
Output is correct |
9 |
Correct |
130 ms |
37044 KB |
Output is correct |
10 |
Correct |
152 ms |
36840 KB |
Output is correct |
11 |
Correct |
168 ms |
22920 KB |
Output is correct |
12 |
Correct |
162 ms |
29788 KB |
Output is correct |
13 |
Correct |
195 ms |
23008 KB |
Output is correct |
14 |
Correct |
295 ms |
36692 KB |
Output is correct |
15 |
Correct |
294 ms |
36684 KB |
Output is correct |
16 |
Correct |
3 ms |
7380 KB |
Output is correct |
17 |
Correct |
4 ms |
7380 KB |
Output is correct |
18 |
Correct |
3 ms |
7380 KB |
Output is correct |
19 |
Correct |
3 ms |
7380 KB |
Output is correct |
20 |
Correct |
3 ms |
7380 KB |
Output is correct |
21 |
Correct |
3 ms |
7380 KB |
Output is correct |
22 |
Correct |
3 ms |
7380 KB |
Output is correct |
23 |
Correct |
3 ms |
7380 KB |
Output is correct |
24 |
Correct |
3 ms |
7252 KB |
Output is correct |
25 |
Correct |
3 ms |
7252 KB |
Output is correct |