제출 #394681

#제출 시각아이디문제언어결과실행 시간메모리
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'; }

컴파일 시 표준 에러 (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...