| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1307964 | ballbreaker | Network (BOI15_net) | C++20 | 1 ms | 14624 KiB |
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
using namespace std;
main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
int cnt[n + 1] = {};
for (int i = 1; i < n; i++) {
int a, b;
cin >> a >> b;
cnt[a]++;
cnt[b]++;
}
vector<int>v;
for (int i = 1; i <= n; i++) {
if (cnt[i] == 1) {
v.push_back(i);
}
}
if (v.size() & 1) {
for (int i = 1; i <= n; i++) {
if (cnt[i] > 1) {
v.push_back(i);
break;
}
}
}
cout << v.size() / 2 << '\n';
for (int i = 0; i < v.size(); i += 2) {
cout << v[i] << ' ' << v[i + 1] << endl;
}
}
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... | ||||
