Submission #102142

#TimeUsernameProblemLanguageResultExecution timeMemory
102142Leonardo_PaesNetwork (BOI15_net)C++11
0 / 100
4 ms384 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 5e5 + 100; int grau[MAXN]; int main(){ int n; cin >> n; for(int i=1; i<n; i++){ int a, b; cin >> a >> b; grau[a]++; grau[b]++; } vector<int> v; for(int i=1; i<=n; i++){ if(grau[i]==1){ v.push_back(i); } } cout << ceil((double)v.size()/2) << endl; for(int i=0; i<v.size(); i+=2){ if(i==v.size()-1)break; cout << v[i] << " " << v[i+1] << "\n"; } if(v.size()%2==1){ cout << v[v.size()-1] << " " << v[v.size()-2] << endl; } }

Compilation message (stderr)

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