Submission #751028

#TimeUsernameProblemLanguageResultExecution timeMemory
751028ljubaNetwork (BOI15_net)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> deg(n); for(int i = 1; i < n; ++i) { int u, v; cin >> u >> v; --u, --v; ++deg[u], ++deg[v]; } vector<int> lisce; for(int i = 0; i < n; ++i) { if(deg[i] == 1) lisce.push_back(i); } assert(lisce.size() != 1); cout << (lisce.size() + 1) / 2 << '\n'; for(int i = 0; i < lisce.size(); i += 2) { int x = lisce[i]; int y = lisce[(i + 1) % lisce.size()]; cout << x + 1 << " " << y + 1 << '\n'; } }

Compilation message (stderr)

net.cpp: In function 'int main()':
net.cpp:31:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i = 0; i < lisce.size(); i += 2) {
      |                    ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...