# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
720324 |
2023-04-08T03:21:34 Z |
Yell0 |
Paths (BOI18_paths) |
C++17 |
|
481 ms |
30812 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MN=3e5+2;
int N,M,K,c[MN],perm[6];
ll dp[6][MN],ans=0;
vector<int> gr[MN];
int main() {
ios::sync_with_stdio(0);cin.tie(0);
cin>>N>>M>>K;
for(int i=1;i<=N;++i) cin>>c[i];
for(int i=1,u,v;i<=M;++i) {
cin>>u>>v;
gr[u].push_back(v);
gr[v].push_back(u);
}
iota(perm+1,perm+1+K,1);
do {
for(int u=1;u<=N;++u) dp[1][u]=c[u]==perm[1];
for(int k=2;k<=K;++k) {
for(int u=1;u<=N;++u) {
dp[k][u]=0;
if(c[u]!=perm[k]) continue;
for(int v:gr[u]) dp[k][u]+=dp[k-1][v];
}
if(is_sorted(perm+1+k,perm+1+K))
for(int u=1;u<=N;++u) ans+=dp[k][u];
}
} while(next_permutation(perm+1,perm+1+K));
cout<<ans<<'\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7380 KB |
Output is correct |
2 |
Correct |
4 ms |
7380 KB |
Output is correct |
3 |
Correct |
4 ms |
7380 KB |
Output is correct |
4 |
Correct |
4 ms |
7380 KB |
Output is correct |
5 |
Correct |
4 ms |
7380 KB |
Output is correct |
6 |
Correct |
4 ms |
7380 KB |
Output is correct |
7 |
Correct |
4 ms |
7388 KB |
Output is correct |
8 |
Correct |
4 ms |
7380 KB |
Output is correct |
9 |
Correct |
4 ms |
7380 KB |
Output is correct |
10 |
Correct |
4 ms |
7384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
13900 KB |
Output is correct |
2 |
Correct |
48 ms |
13260 KB |
Output is correct |
3 |
Correct |
220 ms |
28528 KB |
Output is correct |
4 |
Correct |
83 ms |
15684 KB |
Output is correct |
5 |
Correct |
78 ms |
15436 KB |
Output is correct |
6 |
Correct |
171 ms |
24020 KB |
Output is correct |
7 |
Correct |
227 ms |
28504 KB |
Output is correct |
8 |
Correct |
204 ms |
28992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7380 KB |
Output is correct |
2 |
Correct |
4 ms |
7380 KB |
Output is correct |
3 |
Correct |
4 ms |
7380 KB |
Output is correct |
4 |
Correct |
4 ms |
7380 KB |
Output is correct |
5 |
Correct |
4 ms |
7380 KB |
Output is correct |
6 |
Correct |
4 ms |
7380 KB |
Output is correct |
7 |
Correct |
4 ms |
7388 KB |
Output is correct |
8 |
Correct |
4 ms |
7380 KB |
Output is correct |
9 |
Correct |
4 ms |
7380 KB |
Output is correct |
10 |
Correct |
4 ms |
7384 KB |
Output is correct |
11 |
Correct |
59 ms |
13900 KB |
Output is correct |
12 |
Correct |
48 ms |
13260 KB |
Output is correct |
13 |
Correct |
220 ms |
28528 KB |
Output is correct |
14 |
Correct |
83 ms |
15684 KB |
Output is correct |
15 |
Correct |
78 ms |
15436 KB |
Output is correct |
16 |
Correct |
171 ms |
24020 KB |
Output is correct |
17 |
Correct |
227 ms |
28504 KB |
Output is correct |
18 |
Correct |
204 ms |
28992 KB |
Output is correct |
19 |
Correct |
58 ms |
13904 KB |
Output is correct |
20 |
Correct |
50 ms |
13148 KB |
Output is correct |
21 |
Correct |
233 ms |
28336 KB |
Output is correct |
22 |
Correct |
88 ms |
15688 KB |
Output is correct |
23 |
Correct |
82 ms |
15424 KB |
Output is correct |
24 |
Correct |
151 ms |
23984 KB |
Output is correct |
25 |
Correct |
209 ms |
28424 KB |
Output is correct |
26 |
Correct |
219 ms |
29004 KB |
Output is correct |
27 |
Correct |
52 ms |
13276 KB |
Output is correct |
28 |
Correct |
74 ms |
14960 KB |
Output is correct |
29 |
Correct |
436 ms |
30768 KB |
Output is correct |
30 |
Correct |
247 ms |
22524 KB |
Output is correct |
31 |
Correct |
210 ms |
22516 KB |
Output is correct |
32 |
Correct |
471 ms |
30812 KB |
Output is correct |
33 |
Correct |
4 ms |
7380 KB |
Output is correct |
34 |
Correct |
4 ms |
7372 KB |
Output is correct |
35 |
Correct |
4 ms |
7380 KB |
Output is correct |
36 |
Correct |
4 ms |
7380 KB |
Output is correct |
37 |
Correct |
4 ms |
7380 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 |
7384 KB |
Output is correct |
41 |
Correct |
4 ms |
7380 KB |
Output is correct |
42 |
Correct |
4 ms |
7380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7380 KB |
Output is correct |
2 |
Correct |
34 ms |
9188 KB |
Output is correct |
3 |
Correct |
18 ms |
9220 KB |
Output is correct |
4 |
Correct |
49 ms |
14232 KB |
Output is correct |
5 |
Correct |
42 ms |
14920 KB |
Output is correct |
6 |
Correct |
481 ms |
15768 KB |
Output is correct |
7 |
Correct |
20 ms |
9176 KB |
Output is correct |
8 |
Correct |
94 ms |
15056 KB |
Output is correct |
9 |
Correct |
82 ms |
15724 KB |
Output is correct |
10 |
Correct |
80 ms |
15552 KB |
Output is correct |
11 |
Correct |
172 ms |
12512 KB |
Output is correct |
12 |
Correct |
200 ms |
14696 KB |
Output is correct |
13 |
Correct |
165 ms |
12564 KB |
Output is correct |
14 |
Correct |
414 ms |
15868 KB |
Output is correct |
15 |
Correct |
409 ms |
16000 KB |
Output is correct |
16 |
Correct |
4 ms |
7380 KB |
Output is correct |
17 |
Correct |
4 ms |
7380 KB |
Output is correct |
18 |
Correct |
4 ms |
7380 KB |
Output is correct |
19 |
Correct |
4 ms |
7380 KB |
Output is correct |
20 |
Correct |
4 ms |
7380 KB |
Output is correct |
21 |
Correct |
4 ms |
7380 KB |
Output is correct |
22 |
Correct |
4 ms |
7380 KB |
Output is correct |
23 |
Correct |
4 ms |
7380 KB |
Output is correct |
24 |
Correct |
4 ms |
7376 KB |
Output is correct |
25 |
Correct |
4 ms |
7380 KB |
Output is correct |