제출 #311448

#제출 시각아이디문제언어결과실행 시간메모리
311448vipghn2003Network (BOI15_net)C++14
0 / 100
10 ms12032 KiB
#include<bits/stdc++.h> using namespace std; const int N=5e5+5; int n; vector<int>leaf; vector<int>adj[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin>>n; for(int i=1;i<n;i++) { int u,v; cin>>u>>v; adj[u].push_back(v); adj[v].push_back(u); } for(int i=1;i<=n;i++) if(adj[i].size()==1) leaf.push_back(i); cout<<(leaf.size()+1)/2<<'\n'; for(int i=0;i+1<leaf.size();i+=2) cout<<leaf[i]<<' '<<leaf[i+1]<<'\n'; if(leaf.size()%2) cout<<leaf.back()<<' '<<leaf[0]<<'\n'; }

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

net.cpp: In function 'int main()':
net.cpp:24:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i=0;i+1<leaf.size();i+=2) cout<<leaf[i]<<' '<<leaf[i+1]<<'\n';
      |                 ~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...