Submission #1307964

#TimeUsernameProblemLanguageResultExecution timeMemory
1307964ballbreakerNetwork (BOI15_net)C++20
0 / 100
1 ms14624 KiB
#include<bits/stdc++.h> #pragma GCC optimize("Ofast,unroll-loops") using namespace std; main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int cnt[n + 1] = {}; for (int i = 1; i < n; i++) { int a, b; cin >> a >> b; cnt[a]++; cnt[b]++; } vector<int>v; for (int i = 1; i <= n; i++) { if (cnt[i] == 1) { v.push_back(i); } } if (v.size() & 1) { for (int i = 1; i <= n; i++) { if (cnt[i] > 1) { v.push_back(i); break; } } } cout << v.size() / 2 << '\n'; for (int i = 0; i < v.size(); i += 2) { cout << v[i] << ' ' << v[i + 1] << endl; } }

Compilation message (stderr)

net.cpp:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    4 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...