# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
332629 |
2020-12-03T01:45:00 Z |
YJU |
Power Plant (JOI20_power) |
C++14 |
|
1500 ms |
23472 KB |
#include<bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ll N=4e5+5;
const ll K=350;
const ld pi=acos(-1);
const ll INF=(1LL<<60);
#define SQ(i) ((i)*(i))
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(_a) (ll)_a.size()
ll n,x,y,h[N],dp[N],ans,col[N],sum;
vector<ll> v[N];
string s;
void DFS(ll nd,ll pa){
dp[nd]=0;
for(auto i:v[nd]){
if(i==pa)continue;
DFS(i,nd);
dp[nd]+=dp[i];
}
dp[nd]=max(dp[nd]-col[nd],col[nd]);
return ;
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n;
REP(i,n-1)cin>>x>>y,v[x].pb(y),v[y].pb(x);
cin>>s;
REP(i,n)if(s[i]=='1')col[i+1]=1,++sum;
if(sum>=2)ans=2;else ans=sum;
REP1(i,n){
DFS(i,0);
ans=max(ans,dp[i]);
}
cout<<ans<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
9708 KB |
Output is correct |
2 |
Correct |
7 ms |
9708 KB |
Output is correct |
3 |
Correct |
7 ms |
9708 KB |
Output is correct |
4 |
Correct |
7 ms |
9708 KB |
Output is correct |
5 |
Correct |
8 ms |
9728 KB |
Output is correct |
6 |
Correct |
7 ms |
9708 KB |
Output is correct |
7 |
Correct |
7 ms |
9708 KB |
Output is correct |
8 |
Correct |
7 ms |
9708 KB |
Output is correct |
9 |
Correct |
7 ms |
9708 KB |
Output is correct |
10 |
Correct |
7 ms |
9708 KB |
Output is correct |
11 |
Correct |
8 ms |
9708 KB |
Output is correct |
12 |
Correct |
7 ms |
9708 KB |
Output is correct |
13 |
Correct |
7 ms |
9708 KB |
Output is correct |
14 |
Correct |
7 ms |
9708 KB |
Output is correct |
15 |
Correct |
7 ms |
9708 KB |
Output is correct |
16 |
Correct |
7 ms |
9708 KB |
Output is correct |
17 |
Correct |
7 ms |
9708 KB |
Output is correct |
18 |
Correct |
7 ms |
9856 KB |
Output is correct |
19 |
Correct |
7 ms |
9708 KB |
Output is correct |
20 |
Correct |
7 ms |
9708 KB |
Output is correct |
21 |
Correct |
7 ms |
9728 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
9708 KB |
Output is correct |
2 |
Correct |
7 ms |
9708 KB |
Output is correct |
3 |
Correct |
7 ms |
9708 KB |
Output is correct |
4 |
Correct |
7 ms |
9708 KB |
Output is correct |
5 |
Correct |
8 ms |
9728 KB |
Output is correct |
6 |
Correct |
7 ms |
9708 KB |
Output is correct |
7 |
Correct |
7 ms |
9708 KB |
Output is correct |
8 |
Correct |
7 ms |
9708 KB |
Output is correct |
9 |
Correct |
7 ms |
9708 KB |
Output is correct |
10 |
Correct |
7 ms |
9708 KB |
Output is correct |
11 |
Correct |
8 ms |
9708 KB |
Output is correct |
12 |
Correct |
7 ms |
9708 KB |
Output is correct |
13 |
Correct |
7 ms |
9708 KB |
Output is correct |
14 |
Correct |
7 ms |
9708 KB |
Output is correct |
15 |
Correct |
7 ms |
9708 KB |
Output is correct |
16 |
Correct |
7 ms |
9708 KB |
Output is correct |
17 |
Correct |
7 ms |
9708 KB |
Output is correct |
18 |
Correct |
7 ms |
9856 KB |
Output is correct |
19 |
Correct |
7 ms |
9708 KB |
Output is correct |
20 |
Correct |
7 ms |
9708 KB |
Output is correct |
21 |
Correct |
7 ms |
9728 KB |
Output is correct |
22 |
Correct |
77 ms |
9936 KB |
Output is correct |
23 |
Correct |
77 ms |
9936 KB |
Output is correct |
24 |
Correct |
77 ms |
9836 KB |
Output is correct |
25 |
Correct |
74 ms |
9836 KB |
Output is correct |
26 |
Correct |
75 ms |
9836 KB |
Output is correct |
27 |
Correct |
76 ms |
9836 KB |
Output is correct |
28 |
Correct |
77 ms |
9964 KB |
Output is correct |
29 |
Correct |
108 ms |
9964 KB |
Output is correct |
30 |
Correct |
105 ms |
9964 KB |
Output is correct |
31 |
Correct |
68 ms |
9836 KB |
Output is correct |
32 |
Correct |
69 ms |
9952 KB |
Output is correct |
33 |
Correct |
77 ms |
9836 KB |
Output is correct |
34 |
Correct |
76 ms |
9964 KB |
Output is correct |
35 |
Correct |
76 ms |
9836 KB |
Output is correct |
36 |
Correct |
76 ms |
9836 KB |
Output is correct |
37 |
Correct |
63 ms |
9836 KB |
Output is correct |
38 |
Correct |
68 ms |
9836 KB |
Output is correct |
39 |
Correct |
91 ms |
9964 KB |
Output is correct |
40 |
Correct |
93 ms |
9964 KB |
Output is correct |
41 |
Correct |
93 ms |
9964 KB |
Output is correct |
42 |
Correct |
84 ms |
9964 KB |
Output is correct |
43 |
Correct |
84 ms |
10092 KB |
Output is correct |
44 |
Correct |
78 ms |
9964 KB |
Output is correct |
45 |
Correct |
75 ms |
9964 KB |
Output is correct |
46 |
Correct |
74 ms |
9964 KB |
Output is correct |
47 |
Correct |
76 ms |
9964 KB |
Output is correct |
48 |
Correct |
76 ms |
10092 KB |
Output is correct |
49 |
Correct |
76 ms |
9964 KB |
Output is correct |
50 |
Correct |
74 ms |
9964 KB |
Output is correct |
51 |
Correct |
73 ms |
9964 KB |
Output is correct |
52 |
Correct |
77 ms |
9856 KB |
Output is correct |
53 |
Correct |
71 ms |
9964 KB |
Output is correct |
54 |
Correct |
75 ms |
10092 KB |
Output is correct |
55 |
Correct |
78 ms |
9836 KB |
Output is correct |
56 |
Correct |
43 ms |
9836 KB |
Output is correct |
57 |
Correct |
105 ms |
9964 KB |
Output is correct |
58 |
Correct |
44 ms |
9836 KB |
Output is correct |
59 |
Correct |
44 ms |
9964 KB |
Output is correct |
60 |
Correct |
106 ms |
10092 KB |
Output is correct |
61 |
Correct |
43 ms |
9836 KB |
Output is correct |
62 |
Correct |
108 ms |
9964 KB |
Output is correct |
63 |
Correct |
63 ms |
9936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
9708 KB |
Output is correct |
2 |
Correct |
7 ms |
9708 KB |
Output is correct |
3 |
Correct |
7 ms |
9708 KB |
Output is correct |
4 |
Correct |
7 ms |
9708 KB |
Output is correct |
5 |
Correct |
8 ms |
9728 KB |
Output is correct |
6 |
Correct |
7 ms |
9708 KB |
Output is correct |
7 |
Correct |
7 ms |
9708 KB |
Output is correct |
8 |
Correct |
7 ms |
9708 KB |
Output is correct |
9 |
Correct |
7 ms |
9708 KB |
Output is correct |
10 |
Correct |
7 ms |
9708 KB |
Output is correct |
11 |
Correct |
8 ms |
9708 KB |
Output is correct |
12 |
Correct |
7 ms |
9708 KB |
Output is correct |
13 |
Correct |
7 ms |
9708 KB |
Output is correct |
14 |
Correct |
7 ms |
9708 KB |
Output is correct |
15 |
Correct |
7 ms |
9708 KB |
Output is correct |
16 |
Correct |
7 ms |
9708 KB |
Output is correct |
17 |
Correct |
7 ms |
9708 KB |
Output is correct |
18 |
Correct |
7 ms |
9856 KB |
Output is correct |
19 |
Correct |
7 ms |
9708 KB |
Output is correct |
20 |
Correct |
7 ms |
9708 KB |
Output is correct |
21 |
Correct |
7 ms |
9728 KB |
Output is correct |
22 |
Correct |
77 ms |
9936 KB |
Output is correct |
23 |
Correct |
77 ms |
9936 KB |
Output is correct |
24 |
Correct |
77 ms |
9836 KB |
Output is correct |
25 |
Correct |
74 ms |
9836 KB |
Output is correct |
26 |
Correct |
75 ms |
9836 KB |
Output is correct |
27 |
Correct |
76 ms |
9836 KB |
Output is correct |
28 |
Correct |
77 ms |
9964 KB |
Output is correct |
29 |
Correct |
108 ms |
9964 KB |
Output is correct |
30 |
Correct |
105 ms |
9964 KB |
Output is correct |
31 |
Correct |
68 ms |
9836 KB |
Output is correct |
32 |
Correct |
69 ms |
9952 KB |
Output is correct |
33 |
Correct |
77 ms |
9836 KB |
Output is correct |
34 |
Correct |
76 ms |
9964 KB |
Output is correct |
35 |
Correct |
76 ms |
9836 KB |
Output is correct |
36 |
Correct |
76 ms |
9836 KB |
Output is correct |
37 |
Correct |
63 ms |
9836 KB |
Output is correct |
38 |
Correct |
68 ms |
9836 KB |
Output is correct |
39 |
Correct |
91 ms |
9964 KB |
Output is correct |
40 |
Correct |
93 ms |
9964 KB |
Output is correct |
41 |
Correct |
93 ms |
9964 KB |
Output is correct |
42 |
Correct |
84 ms |
9964 KB |
Output is correct |
43 |
Correct |
84 ms |
10092 KB |
Output is correct |
44 |
Correct |
78 ms |
9964 KB |
Output is correct |
45 |
Correct |
75 ms |
9964 KB |
Output is correct |
46 |
Correct |
74 ms |
9964 KB |
Output is correct |
47 |
Correct |
76 ms |
9964 KB |
Output is correct |
48 |
Correct |
76 ms |
10092 KB |
Output is correct |
49 |
Correct |
76 ms |
9964 KB |
Output is correct |
50 |
Correct |
74 ms |
9964 KB |
Output is correct |
51 |
Correct |
73 ms |
9964 KB |
Output is correct |
52 |
Correct |
77 ms |
9856 KB |
Output is correct |
53 |
Correct |
71 ms |
9964 KB |
Output is correct |
54 |
Correct |
75 ms |
10092 KB |
Output is correct |
55 |
Correct |
78 ms |
9836 KB |
Output is correct |
56 |
Correct |
43 ms |
9836 KB |
Output is correct |
57 |
Correct |
105 ms |
9964 KB |
Output is correct |
58 |
Correct |
44 ms |
9836 KB |
Output is correct |
59 |
Correct |
44 ms |
9964 KB |
Output is correct |
60 |
Correct |
106 ms |
10092 KB |
Output is correct |
61 |
Correct |
43 ms |
9836 KB |
Output is correct |
62 |
Correct |
108 ms |
9964 KB |
Output is correct |
63 |
Correct |
63 ms |
9936 KB |
Output is correct |
64 |
Execution timed out |
1580 ms |
23472 KB |
Time limit exceeded |
65 |
Halted |
0 ms |
0 KB |
- |