# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
558075 | 2022-05-06T18:12:51 Z | groshi | Power Plant (JOI20_power) | C++17 | 172 ms | 25452 KB |
#include<iostream> #include<vector> using namespace std; struct wi{ vector<int> Q; }*w; int wynik=0; string s; int dfs(int x,int ojc) { int ile=0; for(int i=0;i<w[x].Q.size();i++) { int pom=w[x].Q[i]; if(pom==ojc) continue; int k=dfs(pom,x); ile+=k; if(s[x-1]=='1') wynik=max(wynik,k+1); } if(s[x-1]=='1') ile=max(ile-1,1); wynik=max(wynik,ile); return ile; } int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); int n,x,y; cin>>n; w=new wi[n+3]; for(int i=1;i<n;i++) { cin>>x>>y; w[x].Q.push_back(y); w[y].Q.push_back(x); } cin>>s; int k=dfs(1,0); cout<<wynik; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 328 KB | Output is correct |
14 | Correct | 1 ms | 324 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 328 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 328 KB | Output is correct |
14 | Correct | 1 ms | 324 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 328 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 0 ms | 212 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 432 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
28 | Correct | 2 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 468 KB | Output is correct |
30 | Correct | 1 ms | 468 KB | Output is correct |
31 | Correct | 1 ms | 340 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 1 ms | 340 KB | Output is correct |
34 | Correct | 1 ms | 432 KB | Output is correct |
35 | Correct | 1 ms | 428 KB | Output is correct |
36 | Correct | 1 ms | 340 KB | Output is correct |
37 | Correct | 1 ms | 340 KB | Output is correct |
38 | Correct | 1 ms | 468 KB | Output is correct |
39 | Correct | 1 ms | 468 KB | Output is correct |
40 | Correct | 1 ms | 468 KB | Output is correct |
41 | Correct | 1 ms | 468 KB | Output is correct |
42 | Correct | 1 ms | 432 KB | Output is correct |
43 | Correct | 1 ms | 468 KB | Output is correct |
44 | Correct | 1 ms | 468 KB | Output is correct |
45 | Correct | 1 ms | 464 KB | Output is correct |
46 | Correct | 1 ms | 468 KB | Output is correct |
47 | Correct | 2 ms | 428 KB | Output is correct |
48 | Correct | 1 ms | 468 KB | Output is correct |
49 | Correct | 1 ms | 460 KB | Output is correct |
50 | Correct | 2 ms | 468 KB | Output is correct |
51 | Correct | 1 ms | 468 KB | Output is correct |
52 | Correct | 1 ms | 340 KB | Output is correct |
53 | Correct | 1 ms | 468 KB | Output is correct |
54 | Correct | 1 ms | 460 KB | Output is correct |
55 | Correct | 1 ms | 468 KB | Output is correct |
56 | Correct | 2 ms | 468 KB | Output is correct |
57 | Correct | 1 ms | 560 KB | Output is correct |
58 | Correct | 1 ms | 340 KB | Output is correct |
59 | Correct | 1 ms | 468 KB | Output is correct |
60 | Correct | 1 ms | 432 KB | Output is correct |
61 | Correct | 1 ms | 424 KB | Output is correct |
62 | Correct | 1 ms | 468 KB | Output is correct |
63 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 328 KB | Output is correct |
14 | Correct | 1 ms | 324 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 328 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 0 ms | 212 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 432 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
28 | Correct | 2 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 468 KB | Output is correct |
30 | Correct | 1 ms | 468 KB | Output is correct |
31 | Correct | 1 ms | 340 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 1 ms | 340 KB | Output is correct |
34 | Correct | 1 ms | 432 KB | Output is correct |
35 | Correct | 1 ms | 428 KB | Output is correct |
36 | Correct | 1 ms | 340 KB | Output is correct |
37 | Correct | 1 ms | 340 KB | Output is correct |
38 | Correct | 1 ms | 468 KB | Output is correct |
39 | Correct | 1 ms | 468 KB | Output is correct |
40 | Correct | 1 ms | 468 KB | Output is correct |
41 | Correct | 1 ms | 468 KB | Output is correct |
42 | Correct | 1 ms | 432 KB | Output is correct |
43 | Correct | 1 ms | 468 KB | Output is correct |
44 | Correct | 1 ms | 468 KB | Output is correct |
45 | Correct | 1 ms | 464 KB | Output is correct |
46 | Correct | 1 ms | 468 KB | Output is correct |
47 | Correct | 2 ms | 428 KB | Output is correct |
48 | Correct | 1 ms | 468 KB | Output is correct |
49 | Correct | 1 ms | 460 KB | Output is correct |
50 | Correct | 2 ms | 468 KB | Output is correct |
51 | Correct | 1 ms | 468 KB | Output is correct |
52 | Correct | 1 ms | 340 KB | Output is correct |
53 | Correct | 1 ms | 468 KB | Output is correct |
54 | Correct | 1 ms | 460 KB | Output is correct |
55 | Correct | 1 ms | 468 KB | Output is correct |
56 | Correct | 2 ms | 468 KB | Output is correct |
57 | Correct | 1 ms | 560 KB | Output is correct |
58 | Correct | 1 ms | 340 KB | Output is correct |
59 | Correct | 1 ms | 468 KB | Output is correct |
60 | Correct | 1 ms | 432 KB | Output is correct |
61 | Correct | 1 ms | 424 KB | Output is correct |
62 | Correct | 1 ms | 468 KB | Output is correct |
63 | Correct | 1 ms | 340 KB | Output is correct |
64 | Correct | 115 ms | 14672 KB | Output is correct |
65 | Correct | 118 ms | 14496 KB | Output is correct |
66 | Correct | 129 ms | 14472 KB | Output is correct |
67 | Correct | 109 ms | 14420 KB | Output is correct |
68 | Correct | 121 ms | 14512 KB | Output is correct |
69 | Correct | 135 ms | 14508 KB | Output is correct |
70 | Correct | 104 ms | 14472 KB | Output is correct |
71 | Correct | 116 ms | 14456 KB | Output is correct |
72 | Correct | 119 ms | 14536 KB | Output is correct |
73 | Correct | 141 ms | 24432 KB | Output is correct |
74 | Correct | 129 ms | 24372 KB | Output is correct |
75 | Correct | 120 ms | 14384 KB | Output is correct |
76 | Correct | 106 ms | 14392 KB | Output is correct |
77 | Correct | 121 ms | 14400 KB | Output is correct |
78 | Correct | 131 ms | 14472 KB | Output is correct |
79 | Correct | 125 ms | 14428 KB | Output is correct |
80 | Correct | 129 ms | 14424 KB | Output is correct |
81 | Correct | 95 ms | 14788 KB | Output is correct |
82 | Correct | 106 ms | 14536 KB | Output is correct |
83 | Correct | 131 ms | 18464 KB | Output is correct |
84 | Correct | 122 ms | 20120 KB | Output is correct |
85 | Correct | 132 ms | 19864 KB | Output is correct |
86 | Correct | 109 ms | 15424 KB | Output is correct |
87 | Correct | 133 ms | 15036 KB | Output is correct |
88 | Correct | 104 ms | 15404 KB | Output is correct |
89 | Correct | 117 ms | 15504 KB | Output is correct |
90 | Correct | 93 ms | 15328 KB | Output is correct |
91 | Correct | 112 ms | 15468 KB | Output is correct |
92 | Correct | 111 ms | 15692 KB | Output is correct |
93 | Correct | 105 ms | 17560 KB | Output is correct |
94 | Correct | 113 ms | 19076 KB | Output is correct |
95 | Correct | 107 ms | 17880 KB | Output is correct |
96 | Correct | 90 ms | 16464 KB | Output is correct |
97 | Correct | 99 ms | 15332 KB | Output is correct |
98 | Correct | 95 ms | 14912 KB | Output is correct |
99 | Correct | 111 ms | 14860 KB | Output is correct |
100 | Correct | 142 ms | 17220 KB | Output is correct |
101 | Correct | 106 ms | 15636 KB | Output is correct |
102 | Correct | 95 ms | 15064 KB | Output is correct |
103 | Correct | 97 ms | 14912 KB | Output is correct |
104 | Correct | 69 ms | 15220 KB | Output is correct |
105 | Correct | 158 ms | 21916 KB | Output is correct |
106 | Correct | 57 ms | 15168 KB | Output is correct |
107 | Correct | 56 ms | 15104 KB | Output is correct |
108 | Correct | 129 ms | 25088 KB | Output is correct |
109 | Correct | 73 ms | 15276 KB | Output is correct |
110 | Correct | 172 ms | 25452 KB | Output is correct |
111 | Correct | 103 ms | 14408 KB | Output is correct |