Submission #317227

# Submission time Handle Problem Language Result Execution time Memory
317227 2020-10-29T06:38:51 Z tasfiq4 Power Plant (JOI20_power) C++14
0 / 100
3 ms 4992 KB
#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

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 time Memory Grader output
1 Incorrect 3 ms 4992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4992 KB Output isn't correct
2 Halted 0 ms 0 KB -