Submission #939072

#TimeUsernameProblemLanguageResultExecution timeMemory
939072ezzzayNetwork (BOI15_net)C++14
0 / 100
1 ms500 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define pb push_back const int N=3e3+5; bool vis[N]; vector<int>v[N]; vector<pair<int,int>>rts; vector<int>vec; signed main(){ int n; cin>>n; for(int i=1;i<n;i++){ int a,b; cin>>a>>b; v[a].pb(b); v[b].pb(a); rts.pb({a,b}); } for(int i=1;i<=n;i++){ if(v[i].size()==1)vec.pb(i); } cout<<vec.size()/2+vec.size()%2<<endl; for(int i=0;i<vec.size()-1;i+=2){ cout<<vec[i]<<" "<<vec[i+1]<<endl; } if(vec.size()%2==0)return 0; for(auto a:v[vec[vec.size()-1]]){ vis[a]=1; } for(int i=1;i<=n;i++){ if(vis[i]==0){ cout<<i<<" "<<vec[vec.size()-1]; return 0; } } }

Compilation message (stderr)

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