# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
79557 | FutymyClone | Network (BOI15_net) | C++14 | 2 ms | 552 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;
const int N = 5e5 + 5;
int deg[N], n;
vector <int> vec;
int main(){
scanf("%d", &n);
for (int i = 1; i <= n - 1; i++) {
int u, v; scanf("%d %d", &u, &v);
deg[u]++; deg[v]++;
}
for (int i = 1; i <= n; i++) if (deg[i] == 1) vec.push_back(i);
printf("%d\n", ((int)vec.size() + 1) / 2);
for (int i = 0; i < ((int)vec.size() + 1) / 2; i++) printf("%d %d\n", vec[i], vec[i + vec.size() / 2]);
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... |