제출 #32316

#제출 시각아이디문제언어결과실행 시간메모리
32316dqhungdlNetwork (BOI15_net)C++14
100 / 100
766 ms38724 KiB
#include <bits/stdc++.h> using namespace std; int n; bool Free[500005]; vector<int> V,g[500005]; void DFS(int u) { Free[u]=true; if(g[u].size()==1) V.push_back(u); for(int i=0;i<g[u].size();i++) if(Free[g[u][i]]==false) DFS(g[u][i]); } int main() { //ios_base::sync_with_stdio(false); //freopen("NET.INP","r",stdin); scanf("%d",&n); int u,v; for(int i=1;i<n;i++) { scanf("%d%d",&u,&v); g[u].push_back(v); g[v].push_back(u); } DFS(1); int res=(V.size()+1)/2; printf("%d\n",res); for(int i=0;i<res;i++) if(i+V.size()/2<V.size()) printf("%d %d\n",V[i],V[i+V.size()/2]); }

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

net.cpp: In function 'void DFS(int)':
net.cpp:13:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<g[u].size();i++)
                  ^
net.cpp: In function 'int main()':
net.cpp:22:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
net.cpp:26:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&u,&v);
                            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...