Submission #137064

#TimeUsernameProblemLanguageResultExecution timeMemory
137064silxikysNetwork (BOI15_net)C++14
0 / 100
15 ms12156 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int maxn = 5e5+5; int n; vector<int> adj[maxn]; int deg[maxn]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; for (int i = 0; i < n - 1; i++) { int a, b; cin >> a >> b; ++deg[a]; ++deg[b]; } vector<int> leafs; for (int i = 1; i <= n; i++) { if (deg[i] == 1) leafs.push_back(i); } vector<pair<int,int>> ans; for (int i = 0; i < leafs.size(); i += 2) { ans.push_back({leafs[i],leafs[(i+1)%leafs.size()]}); } //output cout << ans.size() << '\n'; for (auto p: ans) { cout << p.first << ' ' << p.second << '\n'; } }

Compilation message (stderr)

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