| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 394757 | Hossein8320 | Network (BOI15_net) | C++17 | 492 ms | 47656 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.
//That's what she said
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define F first
#define S second
using namespace std;
const int maxn = 5e5 + 9, modn = 1e9 + 7;
int n, m, v, u;
vector <int> barg, adj[maxn];
void dfs(int v, int par)
{
if(adj[v].size() == 1) barg.pb(v);
for(auto i : adj[v]) if(i != par) dfs(i, v);
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n;
for(int i = 1; i < n; i++) cin >> v >> u, adj[v].pb(u), adj[u].pb(v);
dfs(1, 1);
cout << (barg.size() + 1) / 2 << '\n';
int s = barg.size() / 2;
for(int i = 0; i < s; i++) cout << barg[i] << " " << barg[i + s] << '\n';
if(s != (barg.size() + 1) / 2) cout << barg[2 * s] << " " << barg[0] << '\n';
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... | ||||
