Submission #738803

#TimeUsernameProblemLanguageResultExecution timeMemory
738803LIFTriumphal arch (POI13_luk)C++14
100 / 100
986 ms23676 KiB
#include<bits/stdc++.h> #include<vector> using namespace std; int n; vector<int> vv[300005]; int check(int cur,int now,int pre) { int siz = 0; for(int i=0;i<vv[now].size();i++) { int xx = vv[now][i]; if(xx != pre) { siz++; siz += check(cur,xx,now); } } siz -= cur; return max(siz,0); } int main() { cin>>n; for(int i=1;i<=n-1;i++) { int xx,yy; cin>>xx>>yy; vv[xx].push_back(yy); vv[yy].push_back(xx); } int l = 0; int r = n; int ans = 0; while(l<=r) { int mid = (l+r)>>1; if(check(mid,1,-1) > 0) { l = mid +1; } else { ans = mid; r = mid-1; } } cout<<ans<<endl; return 0; }

Compilation message (stderr)

luk.cpp: In function 'int check(int, int, int)':
luk.cpp:9:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  for(int i=0;i<vv[now].size();i++)
      |              ~^~~~~~~~~~~~~~~
#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...