Submission #126212

#TimeUsernameProblemLanguageResultExecution timeMemory
126212VardanyanNetwork (BOI15_net)C++14
0 / 100
13 ms12152 KiB
#include <bits/stdc++.h> using namespace std; const int N = 500*1000+5; vector<int> g[N]; int main(){ ios_base::sync_with_stdio(false); int n; cin>>n; for(int i = 1;i<=n-1;i++){ int x,y; cin>>x>>y; g[x].push_back(y); g[y].push_back(x); } vector<int> lf; for(int i = 1;i<=n;i++){ if(g[i].size() == 1) lf.push_back(i); } cout<<(lf.size()+1)/2<<endl; for(int i = 0;i<lf.size()-1;i+=2){ cout<<lf[i]<< " "<<lf[i+1]<<endl; } if(lf.size()%2){ cout<<lf[lf.size()-1]<<" "<<lf[lf.size()-2]<<endl; } return 0; }

Compilation message (stderr)

net.cpp: In function 'int main()':
net.cpp:20:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<lf.size()-1;i+=2){
                   ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...