제출 #90837

#제출 시각아이디문제언어결과실행 시간메모리
90837Vardanyan새로운 문제 (POI13_luk)C++14
0 / 100
337 ms17812 KiB
#include<bits/stdc++.h> using namespace std; const int N = 300*1000+5; int depth[N]; vector<int> g[N]; void dfs(int v,int p = 0){ depth[v] = depth[p]+1; for(int i = 0;i<g[v].size();i++){ int to = g[v][i]; if(to == p) continue; dfs(to,v); } } vector<int> all; bool check(int crew){ if(crew == 3){ cout<<0<<endl; } int tim = 1; int pos = 0; while(pos<all.size()){ for(int i = 0;i<crew;i++){ if(all[pos]<=tim) return false; pos++; if(pos>=all.size()) return true; } tim++; } return true; } int main() { int n; scanf("%d",&n); for(int i = 1;i<=n-1;i++){ int x,y; scanf("%d%d",&x,&y); g[x].push_back(y); g[y].push_back(x); } if(n == 1){ printf("0\n"); return 0; } /*dfs(1); int l = 1; int r = n-1; int ans = n-1; while(l<=r){ int m = (l+r)/2; if(check(m)){ ans = m; r = m-1; } else l = m+1; }*/ int ans = g[1].size(); for(int i = 2;i<=n;i++){ ans = max(ans,int(g[i].size()-1)); } printf("%d\n",ans); return 0; }

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

luk.cpp: In function 'void dfs(int, int)':
luk.cpp:10:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<g[v].size();i++){
                   ~^~~~~~~~~~~~
luk.cpp: In function 'bool check(int)':
luk.cpp:23:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(pos<all.size()){
           ~~~^~~~~~~~~~~
luk.cpp:27:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(pos>=all.size()) return true;
                ~~~^~~~~~~~~~~~
luk.cpp: In function 'int main()':
luk.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
luk.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&x,&y);
         ~~~~~^~~~~~~~~~~~~~
#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...