Submission #764944

#TimeUsernameProblemLanguageResultExecution timeMemory
764944vjudge1Network (BOI15_net)C++14
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> #define pb push_back using namespace std; int main() { int n; cin>>n; bool t[n][n]; memset(t, 0, sizeof t); for(int i = 0; i<n-1; i++){ int x, y; cin>>x>>y; t[x-1][y-1]=1; t[y-1][x-1]=1; } vector<int>one; for(int i = 0; i<n; i++){ int cnt=0; for(int j = 0; j<n; j++){ if(t[i][j]==1) cnt++; if(cnt>=2){ j=n-1; continue; } } if(cnt<2) one.pb(i+1); } int s = one.size()/2+one.size()%2; cout<<s<<'\n'; for(int i = 0; i<one.size()/2; i++){ cout<<one[i*2]<<' '<<one[i*2+1]<<'\n'; } if(s%2!=0) cout<<one[one.size()-1]<<' '<<one[0]; }

Compilation message (stderr)

net.cpp: In function 'int main()':
net.cpp:31:18: 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<one.size()/2; i++){
      |                 ~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...