Submission #1038217

#TimeUsernameProblemLanguageResultExecution timeMemory
1038217codexistentNetwork (BOI15_net)C++14
0 / 100
3 ms12184 KiB
#include <bits/stdc++.h> using namespace std; #define MAXN 500005 #define FOR(i, a, b) for(int i = a; i <= b; i++) int n; vector<int> e[MAXN]; int main(){ cin >> n; FOR(i, 1, n - 1){ int a, b; cin >> a >> b; e[a].push_back(b); e[b].push_back(a); } vector<int> n2; FOR(i, 1, n){ if(e[i].size() == 1){ n2.push_back(i); } } cout << (n2.size() + 1) / 2 << endl; for(int i = 0; i <= n2.size() - 1; i += 2){ if(i == n2.size() - 1){ cout << 1 << " " << n2[i] << endl; }else{ cout << n2[i] << " " << n2[i + 1] << endl; } } }

Compilation message (stderr)

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