제출 #85212

#제출 시각아이디문제언어결과실행 시간메모리
85212Mahmoud_AdelNetwork (BOI15_net)C++14
0 / 100
14 ms12464 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int ll; const int N = 5e5+5; vector<int> adj[N]; int main() { int n; cin >> n; for(int i=0; i<n-1; i++) { int x, y; cin >> x >> y; x--, y--; adj[x].push_back(y), adj[y].push_back(x); } vector<int> vec; for(int i=0; i<n; i++) if(adj[i].size() == 1) vec.push_back(i); if(vec.size()%2) { cout << vec.size()/2 + 1 << endl; cout << vec[0]+1 << " " << vec[1]+1 << endl; for(int i=1; i<vec.size()-1; i+=2) cout << vec[i]+1 << " " << vec[i+1]+1 << endl; } else { cout << vec.size()/2 << endl; for(int i=0; i<vec.size()-1; i+=2) cout << vec[i]+1 << " " << vec[i+1]+1 << endl; } }

컴파일 시 표준 에러 (stderr) 메시지

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