# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
546667 | Jomnoi | Network (BOI15_net) | C++17 | 1 ms | 328 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define DEBUG 0
using namespace std;
const int N = 5e5 + 10;
int degree[N];
int main() {
cin.tie(0)->sync_with_stdio(0);
int n;
cin >> n;
for(int i = 1; i <= n - 1; i++) {
int a, b;
cin >> a >> b;
degree[a]++;
degree[b]++;
}
vector <int> vec;
for(int i = 1; i <= n; i++) {
if(degree[i] == 1) {
vec.push_back(i);
}
}
cout << (vec.size() + 1) / 2 << '\n';
for(int i = 1; i < vec.size(); i += 2) {
cout << vec[i - 1] << ' ' << vec[i] << '\n';
}
if(vec.size() % 2 == 1) {
cout << vec.back() << ' ' << vec.front();
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |