#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,b,maxi=0;
vector<vector<ll>> graph;
ll degree[300000];
void solve(ll now,ll cantiadja,ll dia,ll res,ll ante){
if(dia>=n){
return;
}
res=max(res,((cantiadja-1)/dia)+1);
maxi=max(maxi,res);
for(auto u:graph[now]){
if(u==ante){
solve(u,cantiadja,dia+1,res,now);
}else{
solve(u,cantiadja+degree[u]-1,dia+1,res,now);
}
}
}
int main(){
scanf("%lld",&n);
graph.resize(n);
for(int i=1;i<n;i++){
scanf("%lld%lld",&a,&b);
a--;b--;
degree[a]++;degree[b]++;
graph[a].push_back(b);
graph[b].push_back(a);
}
solve(0,degree[0],1,0,-1);
printf("%lld",maxi);
}
컴파일 시 표준 에러 (stderr) 메시지
luk.cpp: In function 'int main()':
luk.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
22 | scanf("%lld",&n);
| ~~~~~^~~~~~~~~~~
luk.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
25 | scanf("%lld%lld",&a,&b);
| ~~~~~^~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |