Submission #95940

#TimeUsernameProblemLanguageResultExecution timeMemory
95940luciocfNetwork (BOI15_net)C++14
0 / 100
12 ms12024 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 5e5+10; typedef pair<int, int> pii; vector<int> grafo[maxn], leaf; int main(void) { srand(1001234545); int n; cin >> n; for (int i = 1; i < n; i++) { int u, v; cin >> u >> v; grafo[u].push_back(v); grafo[v].push_back(u); } int root; for (int i = 1; i <= n; i++) { if (grafo[i].size() > 1) root = i; else leaf.push_back(i); } if (leaf.size()&1) leaf.push_back(root); int ans = leaf.size()/2; random_shuffle(leaf.begin(), leaf.end()); cout << ans << "\n"; for (int i = 0; i < leaf.size(); i += 2) cout << leaf[i] << " " << leaf[i+1] << "\n"; }

Compilation message (stderr)

net.cpp: In function 'int main()':
net.cpp:41:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < leaf.size(); i += 2)
                  ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...