Submission #317227

#TimeUsernameProblemLanguageResultExecution timeMemory
317227tasfiq4Power Plant (JOI20_power)C++14
0 / 100
3 ms4992 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int,int > pii; typedef long long int lld; #define pi acos(-1) #define fr(i,m,n) for(i=m;i<n;i++) #define fu(i,m,n) for(i=m;i>=n;i--) #define vec vector<int> #define pb push_back #define pp pop_back() #define ft first #define sd second #define all(v) v.begin(),v.end() #define mom(ara) memset(ara,0,sizeof(ara)); #define m1m(ara) memset(ara,-1,sizeof(ara)); #define endl "\n" #define eps 1.19209e-07 vec adj[200010]; int val[200010],dp[200010],ans=0; void dfs(int u ,int p) { int sum=0,mx=0; for(auto v:adj[u]) { if(v==p) continue; dfs(v,u); sum+=dp[v]; mx=max(mx,dp[v]+1); } if(val[u]) ans=max(ans,max(mx,sum-1)); else ans=max(ans,sum); dp[u]=max(val[u],sum-val[u]); } int main() {ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); int i,j,k,a,b,c,x,y,z,n,m,t; cin>>n; string s; fr(i,1,n){ cin>>a>>b; adj[a].pb(b); adj[b].pb(a); } getline(cin,s); cin>>s; fr(i,0,s.size()) { if(s[i]=='1') val[i+1]=1; } dfs(1,0); cout<<ans<<endl; }

Compilation message (stderr)

power.cpp: In function 'int main()':
power.cpp:6:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 | #define fr(i,m,n) for(i=m;i<n;i++)
......
   46 |     fr(i,0,s.size())
      |        ~~~~~~~~~~~~         
power.cpp:46:5: note: in expansion of macro 'fr'
   46 |     fr(i,0,s.size())
      |     ^~
power.cpp:36:11: warning: unused variable 'j' [-Wunused-variable]
   36 |     int i,j,k,a,b,c,x,y,z,n,m,t;
      |           ^
power.cpp:36:13: warning: unused variable 'k' [-Wunused-variable]
   36 |     int i,j,k,a,b,c,x,y,z,n,m,t;
      |             ^
power.cpp:36:19: warning: unused variable 'c' [-Wunused-variable]
   36 |     int i,j,k,a,b,c,x,y,z,n,m,t;
      |                   ^
power.cpp:36:21: warning: unused variable 'x' [-Wunused-variable]
   36 |     int i,j,k,a,b,c,x,y,z,n,m,t;
      |                     ^
power.cpp:36:23: warning: unused variable 'y' [-Wunused-variable]
   36 |     int i,j,k,a,b,c,x,y,z,n,m,t;
      |                       ^
power.cpp:36:25: warning: unused variable 'z' [-Wunused-variable]
   36 |     int i,j,k,a,b,c,x,y,z,n,m,t;
      |                         ^
power.cpp:36:29: warning: unused variable 'm' [-Wunused-variable]
   36 |     int i,j,k,a,b,c,x,y,z,n,m,t;
      |                             ^
power.cpp:36:31: warning: unused variable 't' [-Wunused-variable]
   36 |     int i,j,k,a,b,c,x,y,z,n,m,t;
      |                               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...