# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1019860 |
2024-07-11T09:55:56 Z |
Andrey |
Power Plant (JOI20_power) |
C++14 |
|
1500 ms |
15588 KB |
#include<bits/stdc++.h>
using namespace std;
vector<int> haha[200001];
vector<int> dp(200001);
vector<int> col(200001);
void dfs(int a, int t) {
int sb = 0;
for(int v: haha[a]) {
if(v != t) {
dfs(v,a);
sb+=dp[v];
}
}
sb-=col[a];
dp[a] = col[a];
dp[a] = max(dp[a],sb);
}
int main()
{
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
cout.tie(NULL);
int n,a,b,ans = 0;
cin >> n;
for(int i = 0; i < n-1; i++) {
cin >> a >> b;
haha[a].push_back(b);
haha[b].push_back(a);
}
for(int i = 1; i <= n; i++) {
char a;
cin >> a;
if(a == '1') {
col[i] = 1;
}
}
for(int i = 1; i <= n; i++) {
if(col[i]) {
dfs(i,-1);
int sb = 0;
for(int v: haha[i]) {
sb = max(dp[v],sb);
}
sb++;
ans = max(ans,sb);
}
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
6492 KB |
Output is correct |
2 |
Correct |
3 ms |
6664 KB |
Output is correct |
3 |
Correct |
3 ms |
6492 KB |
Output is correct |
4 |
Correct |
2 ms |
6492 KB |
Output is correct |
5 |
Correct |
3 ms |
6492 KB |
Output is correct |
6 |
Correct |
3 ms |
6608 KB |
Output is correct |
7 |
Correct |
3 ms |
6488 KB |
Output is correct |
8 |
Correct |
3 ms |
6492 KB |
Output is correct |
9 |
Correct |
3 ms |
6488 KB |
Output is correct |
10 |
Correct |
3 ms |
6492 KB |
Output is correct |
11 |
Correct |
3 ms |
6732 KB |
Output is correct |
12 |
Correct |
3 ms |
6492 KB |
Output is correct |
13 |
Correct |
3 ms |
6596 KB |
Output is correct |
14 |
Correct |
3 ms |
6492 KB |
Output is correct |
15 |
Correct |
3 ms |
6492 KB |
Output is correct |
16 |
Correct |
3 ms |
6748 KB |
Output is correct |
17 |
Correct |
3 ms |
6640 KB |
Output is correct |
18 |
Correct |
4 ms |
6736 KB |
Output is correct |
19 |
Correct |
3 ms |
6492 KB |
Output is correct |
20 |
Correct |
3 ms |
6492 KB |
Output is correct |
21 |
Correct |
3 ms |
6492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
6492 KB |
Output is correct |
2 |
Correct |
3 ms |
6664 KB |
Output is correct |
3 |
Correct |
3 ms |
6492 KB |
Output is correct |
4 |
Correct |
2 ms |
6492 KB |
Output is correct |
5 |
Correct |
3 ms |
6492 KB |
Output is correct |
6 |
Correct |
3 ms |
6608 KB |
Output is correct |
7 |
Correct |
3 ms |
6488 KB |
Output is correct |
8 |
Correct |
3 ms |
6492 KB |
Output is correct |
9 |
Correct |
3 ms |
6488 KB |
Output is correct |
10 |
Correct |
3 ms |
6492 KB |
Output is correct |
11 |
Correct |
3 ms |
6732 KB |
Output is correct |
12 |
Correct |
3 ms |
6492 KB |
Output is correct |
13 |
Correct |
3 ms |
6596 KB |
Output is correct |
14 |
Correct |
3 ms |
6492 KB |
Output is correct |
15 |
Correct |
3 ms |
6492 KB |
Output is correct |
16 |
Correct |
3 ms |
6748 KB |
Output is correct |
17 |
Correct |
3 ms |
6640 KB |
Output is correct |
18 |
Correct |
4 ms |
6736 KB |
Output is correct |
19 |
Correct |
3 ms |
6492 KB |
Output is correct |
20 |
Correct |
3 ms |
6492 KB |
Output is correct |
21 |
Correct |
3 ms |
6492 KB |
Output is correct |
22 |
Correct |
40 ms |
6748 KB |
Output is correct |
23 |
Correct |
33 ms |
6744 KB |
Output is correct |
24 |
Correct |
28 ms |
6748 KB |
Output is correct |
25 |
Correct |
19 ms |
6824 KB |
Output is correct |
26 |
Correct |
11 ms |
6748 KB |
Output is correct |
27 |
Correct |
6 ms |
6748 KB |
Output is correct |
28 |
Correct |
4 ms |
6748 KB |
Output is correct |
29 |
Correct |
60 ms |
6748 KB |
Output is correct |
30 |
Correct |
28 ms |
6744 KB |
Output is correct |
31 |
Correct |
34 ms |
6744 KB |
Output is correct |
32 |
Correct |
20 ms |
7000 KB |
Output is correct |
33 |
Correct |
35 ms |
6748 KB |
Output is correct |
34 |
Correct |
21 ms |
6820 KB |
Output is correct |
35 |
Correct |
13 ms |
6820 KB |
Output is correct |
36 |
Correct |
7 ms |
6748 KB |
Output is correct |
37 |
Correct |
22 ms |
6744 KB |
Output is correct |
38 |
Correct |
18 ms |
6744 KB |
Output is correct |
39 |
Correct |
40 ms |
6748 KB |
Output is correct |
40 |
Correct |
22 ms |
6748 KB |
Output is correct |
41 |
Correct |
13 ms |
6748 KB |
Output is correct |
42 |
Correct |
20 ms |
6748 KB |
Output is correct |
43 |
Correct |
7 ms |
6748 KB |
Output is correct |
44 |
Correct |
35 ms |
6748 KB |
Output is correct |
45 |
Correct |
28 ms |
6744 KB |
Output is correct |
46 |
Correct |
19 ms |
6856 KB |
Output is correct |
47 |
Correct |
13 ms |
6748 KB |
Output is correct |
48 |
Correct |
36 ms |
6748 KB |
Output is correct |
49 |
Correct |
37 ms |
6748 KB |
Output is correct |
50 |
Correct |
36 ms |
6744 KB |
Output is correct |
51 |
Correct |
37 ms |
6744 KB |
Output is correct |
52 |
Correct |
33 ms |
6748 KB |
Output is correct |
53 |
Correct |
25 ms |
6748 KB |
Output is correct |
54 |
Correct |
35 ms |
6748 KB |
Output is correct |
55 |
Correct |
34 ms |
6744 KB |
Output is correct |
56 |
Correct |
3 ms |
6748 KB |
Output is correct |
57 |
Correct |
3 ms |
6748 KB |
Output is correct |
58 |
Correct |
19 ms |
6836 KB |
Output is correct |
59 |
Correct |
19 ms |
6748 KB |
Output is correct |
60 |
Correct |
3 ms |
6748 KB |
Output is correct |
61 |
Correct |
3 ms |
6748 KB |
Output is correct |
62 |
Correct |
4 ms |
6744 KB |
Output is correct |
63 |
Correct |
28 ms |
6748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
6492 KB |
Output is correct |
2 |
Correct |
3 ms |
6664 KB |
Output is correct |
3 |
Correct |
3 ms |
6492 KB |
Output is correct |
4 |
Correct |
2 ms |
6492 KB |
Output is correct |
5 |
Correct |
3 ms |
6492 KB |
Output is correct |
6 |
Correct |
3 ms |
6608 KB |
Output is correct |
7 |
Correct |
3 ms |
6488 KB |
Output is correct |
8 |
Correct |
3 ms |
6492 KB |
Output is correct |
9 |
Correct |
3 ms |
6488 KB |
Output is correct |
10 |
Correct |
3 ms |
6492 KB |
Output is correct |
11 |
Correct |
3 ms |
6732 KB |
Output is correct |
12 |
Correct |
3 ms |
6492 KB |
Output is correct |
13 |
Correct |
3 ms |
6596 KB |
Output is correct |
14 |
Correct |
3 ms |
6492 KB |
Output is correct |
15 |
Correct |
3 ms |
6492 KB |
Output is correct |
16 |
Correct |
3 ms |
6748 KB |
Output is correct |
17 |
Correct |
3 ms |
6640 KB |
Output is correct |
18 |
Correct |
4 ms |
6736 KB |
Output is correct |
19 |
Correct |
3 ms |
6492 KB |
Output is correct |
20 |
Correct |
3 ms |
6492 KB |
Output is correct |
21 |
Correct |
3 ms |
6492 KB |
Output is correct |
22 |
Correct |
40 ms |
6748 KB |
Output is correct |
23 |
Correct |
33 ms |
6744 KB |
Output is correct |
24 |
Correct |
28 ms |
6748 KB |
Output is correct |
25 |
Correct |
19 ms |
6824 KB |
Output is correct |
26 |
Correct |
11 ms |
6748 KB |
Output is correct |
27 |
Correct |
6 ms |
6748 KB |
Output is correct |
28 |
Correct |
4 ms |
6748 KB |
Output is correct |
29 |
Correct |
60 ms |
6748 KB |
Output is correct |
30 |
Correct |
28 ms |
6744 KB |
Output is correct |
31 |
Correct |
34 ms |
6744 KB |
Output is correct |
32 |
Correct |
20 ms |
7000 KB |
Output is correct |
33 |
Correct |
35 ms |
6748 KB |
Output is correct |
34 |
Correct |
21 ms |
6820 KB |
Output is correct |
35 |
Correct |
13 ms |
6820 KB |
Output is correct |
36 |
Correct |
7 ms |
6748 KB |
Output is correct |
37 |
Correct |
22 ms |
6744 KB |
Output is correct |
38 |
Correct |
18 ms |
6744 KB |
Output is correct |
39 |
Correct |
40 ms |
6748 KB |
Output is correct |
40 |
Correct |
22 ms |
6748 KB |
Output is correct |
41 |
Correct |
13 ms |
6748 KB |
Output is correct |
42 |
Correct |
20 ms |
6748 KB |
Output is correct |
43 |
Correct |
7 ms |
6748 KB |
Output is correct |
44 |
Correct |
35 ms |
6748 KB |
Output is correct |
45 |
Correct |
28 ms |
6744 KB |
Output is correct |
46 |
Correct |
19 ms |
6856 KB |
Output is correct |
47 |
Correct |
13 ms |
6748 KB |
Output is correct |
48 |
Correct |
36 ms |
6748 KB |
Output is correct |
49 |
Correct |
37 ms |
6748 KB |
Output is correct |
50 |
Correct |
36 ms |
6744 KB |
Output is correct |
51 |
Correct |
37 ms |
6744 KB |
Output is correct |
52 |
Correct |
33 ms |
6748 KB |
Output is correct |
53 |
Correct |
25 ms |
6748 KB |
Output is correct |
54 |
Correct |
35 ms |
6748 KB |
Output is correct |
55 |
Correct |
34 ms |
6744 KB |
Output is correct |
56 |
Correct |
3 ms |
6748 KB |
Output is correct |
57 |
Correct |
3 ms |
6748 KB |
Output is correct |
58 |
Correct |
19 ms |
6836 KB |
Output is correct |
59 |
Correct |
19 ms |
6748 KB |
Output is correct |
60 |
Correct |
3 ms |
6748 KB |
Output is correct |
61 |
Correct |
3 ms |
6748 KB |
Output is correct |
62 |
Correct |
4 ms |
6744 KB |
Output is correct |
63 |
Correct |
28 ms |
6748 KB |
Output is correct |
64 |
Execution timed out |
1564 ms |
15588 KB |
Time limit exceeded |
65 |
Halted |
0 ms |
0 KB |
- |