# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1038217 | codexistent | Network (BOI15_net) | C++14 | 3 ms | 12184 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;
#define MAXN 500005
#define FOR(i, a, b) for(int i = a; i <= b; i++)
int n;
vector<int> e[MAXN];
int main(){
cin >> n;
FOR(i, 1, n - 1){
int a, b;
cin >> a >> b;
e[a].push_back(b);
e[b].push_back(a);
}
vector<int> n2;
FOR(i, 1, n){
if(e[i].size() == 1){
n2.push_back(i);
}
}
cout << (n2.size() + 1) / 2 << endl;
for(int i = 0; i <= n2.size() - 1; i += 2){
if(i == n2.size() - 1){
cout << 1 << " " << n2[i] << endl;
}else{
cout << n2[i] << " " << n2[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... |