제출 #203241

#제출 시각아이디문제언어결과실행 시간메모리
203241MKopchev새로운 문제 (POI13_luk)C++14
100 / 100
893 ms26488 KiB
#include<bits/stdc++.h> using namespace std; const int nmax=3e5+42; int n; vector<int> adj[nmax]; int MX; int dfs(int node,int parent) { int adj_size=0,more=0; for(auto k:adj[node]) if(k!=parent) { adj_size++; more=more+dfs(k,node); } int ret=adj_size+more-MX; ret=max(ret,0); return ret; } bool can(int current) { MX=current; return dfs(1,0)==0; } int main() { scanf("%i",&n); int u,v; for(int i=1;i<n;i++) { scanf("%i%i",&u,&v); adj[u].push_back(v); adj[v].push_back(u); } int ok=n-1,not_ok=-1; while(ok-not_ok>1) { int av=(ok+not_ok)/2; if(can(av))ok=av; else not_ok=av; } printf("%i\n",ok); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

luk.cpp: In function 'int main()':
luk.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i",&n);
     ~~~~~^~~~~~~~~
luk.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i%i",&u,&v);
         ~~~~~^~~~~~~~~~~~~~
#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...