제출 #394602

#제출 시각아이디문제언어결과실행 시간메모리
394602alirezasamimi100Network (BOI15_net)C++17
100 / 100
463 ms46140 KiB
#include <bits/stdc++.h> //#pragma GCC optimize("Ofast") /*#pragma comment(linker, "/stack:200000000") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/ #pragma GCC optimize("O2") /*#pragma GCC optimize("unroll-loops") #pragma GCC target("avx,avx2,sse,sse2,fma")*/ using namespace std; using ll = long long int; #define F first #define S second #define pb push_back #define mp make_pair #define lc v<<1 #define rc v<<1|1 #define fast_io ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); const int N=5e5+10,LN=20,M=1e5+4,SQ=350,B=737,inf=1e9; const ll INF=1e18; const int MH=1000696969,MOD=1000000007 /*998244353*/; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using pll=pair<ll,ll>; using pii=pair<int,int>; #define ordered_set tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update> ll pow(ll x, ll y, ll mod){ ll ans=1; while (y != 0) { if (y & 1) ans = ans * x % mod; y >>= 1; x = x * x % mod; } return ans; } ll n; vector<ll> adj[N],le; void dfs(ll v, ll p){ if(adj[v].size()==1) le.pb(v); for(ll u : adj[v]){ if(u!=p) dfs(u,v); } } int main(){ fast_io; cin >> n; for(ll i=1; i<n; i++){ ll v,u; cin >> v >> u; adj[v].pb(u); adj[u].pb(v); } dfs(1,0); ll k=(le.size()+1)/2,t=le.size()/2; cout << k << '\n'; for(ll i=0; i<k; i++){ cout << le[i] << ' ' << le[i+t] << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...