Submission #394681

#TimeUsernameProblemLanguageResultExecution timeMemory
394681MahdiBahramianNetwork (BOI15_net)C++17
100 / 100
761 ms45216 KiB
#include<bits/stdc++.h> #define pb push_back using namespace std; const int Max = 5e5 + 10; vector<int> N[Max]; vector<int> L; void DFS(int v , int p = 0) { if(N[v].size() == 1) L.pb(v); for(int u : N[v]) if(u != p) DFS(u , v); } int main() { int n; cin >> n; for(int i = 1 , a , b ; i < n ; i++) cin >> a >> b , N[a].pb(b) , N[b].pb(a); DFS(1); cout << (L.size() + 1) / 2 << '\n'; for(int i = 0 , j = L.size() / 2 ; j < L.size() ; i++ , j++) cout << L[i] << ' ' << L[j] << '\n'; }

Compilation message (stderr)

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