제출 #252222

#제출 시각아이디문제언어결과실행 시간메모리
252222BlagojceNetwork (BOI15_net)C++11
0 / 100
1 ms384 KiB
#include <bits/stdc++.h> #define fr(i, n, m) for(int i = (n); i < (m); i ++) #define pb push_back #define st first #define nd second #define pq priority_queue #define all(x) begin(x), end(x) #include <time.h> #include <cmath> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; const int i_inf = 1e9; const ll inf = 1e18; const ll mod = 1000000007; const ld eps = 1e-13; const ld pi = 3.14159265359; mt19937 _rand(time(NULL)); clock_t timer = clock(); const int mxn = 1e5; int n; void solve(){ cin >> n; int deg[n]; memset(deg, 0, sizeof(deg)); fr(i, 0, n-1){ int u, v; cin >> u >> v; --u, --v; ++deg[u]; ++deg[v]; } vector<pii> v; int pr = -1; fr(i, 0, n){ if(deg[i] == 1){ if(pr == -1) pr = i; else{ v.pb({pr, i}); pr = -1; } } } if(pr != -1){ if(pr == 0) ++pr; v.pb({0, pr}); } cout<<v.size()<<endl; for(auto u : v) cout<<u.st+1<<' '<<u.nd+1<<endl; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...