Submission #1013900

#TimeUsernameProblemLanguageResultExecution timeMemory
1013900AlmontherTriumphal arch (POI13_luk)C++98
0 / 100
321 ms39032 KiB
#include <bits/stdc++.h> #define suiii ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define ll long long #define co cout<< //#pragma GCC optimize("O3,Ofast,unroll-loops") //#pragma GCC target("avx2,sse3,sse4,avx") using namespace std; //stuff ll n; vector<ll>v[1000001]; bool bfs(ll x){ queue<array<ll,3>>q; ll extra=0,mx=0; q.push({1,-1,1}); while(q.size()){ auto inp=q.front(); q.pop(); ll a,last,dep; a=inp[0]; last=inp[1]; dep=inp[2]; if(mx<dep){ extra+=x; mx=dep; } for(auto i:v[a]){ if(i==last) continue; extra--; q.push({i,a,dep+1}); } if(extra<0) return 0; } return 1; } void solve(){ cin>>n; for(int i=0;i<n-1;i++){ ll a,b; cin>>a>>b; v[a].push_back(b); v[b].push_back(a); } ll l,r,ans=0; l=0,r=n; while(l<=r){ ll mid=(l+r)/2; if(bfs(mid)){ r=mid-1; ans=mid; } else l=mid+1; } co ans; } int main() { suiii int tt=1; // cin>>tt; while(tt--){ solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...