Submission #410595

#TimeUsernameProblemLanguageResultExecution timeMemory
410595iulia13Network (BOI15_net)C++14
0 / 100
9 ms12044 KiB
#include <iostream> #include <vector> using namespace std; const int N = 500005; vector <int> g[N]; int v[N]; int main() { int n, i, nr = 0, a, b; cin >> n; for (i = 1; i < n; i++) { cin >> a >> b; g[a].push_back(b); g[b].push_back(a); } for (i = 1; i <= n; i++) if (g[i].size() == 1) v[++nr] = i; if (nr % 2) v[++nr] = v[1]; cout << nr / 2; for (i = 1; i <= nr; i += 2) cout << endl << v[i] << " " << v[i + 1]; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...