# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
751028 | ljuba | Network (BOI15_net) | C++17 | 1 ms | 212 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>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<int> deg(n);
for(int i = 1; i < n; ++i) {
int u, v;
cin >> u >> v;
--u, --v;
++deg[u], ++deg[v];
}
vector<int> lisce;
for(int i = 0; i < n; ++i) {
if(deg[i] == 1) lisce.push_back(i);
}
assert(lisce.size() != 1);
cout << (lisce.size() + 1) / 2 << '\n';
for(int i = 0; i < lisce.size(); i += 2) {
int x = lisce[i];
int y = lisce[(i + 1) % lisce.size()];
cout << x + 1 << " " << y + 1 << '\n';
}
}
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... |