# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
932908 |
2024-02-24T13:15:28 Z |
Soshi85 |
Network (BOI15_net) |
C++14 |
|
0 ms |
0 KB |
#include<bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
#define pb push_back
#define F first
#define S second
#define len(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define file freopen("matrix.txt", "r", stdin);freopen("a.out", "w", stdout);
#define kill(x) {cout << x << '\n'; continue;}
#define int long long
#define double long double
const int maxn = 5e5 + 5, LG = 20, MOD = 1e9+7;// 998244353
const ll inf = 1061109567;
//priority_queue< pii , vector<pii> , greater<pii> pq;
int n;
vector<int> g[maxn], l;
void dfs(int v = 1, int par = 0) {
if(len(g[v]) == 1) l.pb(v);
for(int u : g[v]) if(u ^ par) dfs(u, v);
}
signed main() {
ios::sync_with_stdio(0), cin.tie(0);
cin >> n;
for(int i =0; i<n-1; ++i) {
int v, u;
cin >> v >> u;
g[v].pb(u);
g[u].pb(v);
}
dfs();
int t = (len(l) + 1)/2
cout << t << '\n';
for(int i = 0; i < t; ++i)
cout << l[i] << ' ' << l[i+len(l)/2] << '\n';
}
Compilation message
net.cpp: In function 'int main()':
net.cpp:48:2: error: expected ',' or ';' before 'cout'
48 | cout << t << '\n';
| ^~~~