Submission #151230

#TimeUsernameProblemLanguageResultExecution timeMemory
151230cfalasNetwork (BOI15_net)C++14
0 / 100
2 ms380 KiB
#include<bits/stdc++.h> using namespace std; int main(){ int n; vector<int> ans; cin>>n; int a[n+1] = {}; for(int i=0;i<=n;i++) a[i]=0; for(int i=0;i<n-1;i++){ int b, c; cin>>b>>c; a[b]++; a[c]++; } for(int i=1;i<=n;i++){ if(a[i]<2) ans.push_back(i); } cout<<(ans.size()+1)/2<<endl; for(int i=0;i<(ans.size()+1)/2;i++){ cout<<ans[i]<<" "<<ans[(i+(ans.size()+1)/2)%ans.size()]<<endl; } }

Compilation message (stderr)

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