제출 #529317

#제출 시각아이디문제언어결과실행 시간메모리
529317Alex_tz307Network (BOI15_net)C++17
0 / 100
1 ms316 KiB
#include <bits/stdc++.h> using namespace std; void testCase() { int n; cin >> n; vector<int> d(n + 1); for (int i = 1; i < n; ++i) { int u, v; cin >> u >> v; d[u] += 1; d[v] += 1; } vector<int> a; for (int i = 1; i <= n; ++i) { if (d[i] == 1) { a.emplace_back(i); } } cout << (a.size() + 1) / 2 << '\n'; for (int i = 0; i < (int)a.size(); i += 2) { cout << a[i] << ' ' << a[(i + 1) % a.size()] << '\n'; } } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int tests = 1; for (int tc = 0; tc < tests; ++tc) { testCase(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...