Submission #49445

#TimeUsernameProblemLanguageResultExecution timeMemory
49445faishol27Network (BOI15_net)C++14
0 / 100
3 ms644 KiB
#include <bits/stdc++.h> using namespace std; #define PUB push_back int N; int way[500005]; vector<int>leaf; int main(){ cin >> N; for(int i = 0;i<N-1;i++){ int x, y; cin >> x >> y; way[x]++; way[y]++; } for(int i=1;i<=N;i++) if(way[i]==1) leaf.PUB(i); if(leaf.size()%2 == 1) leaf.PUB(1); cout << leaf.size()/2 << endl; for(int i=0;i<leaf.size();i+=2){ cout << leaf[i] << " " << leaf[i+1] << endl; } }

Compilation message (stderr)

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