Submission #958513

#TimeUsernameProblemLanguageResultExecution timeMemory
958513YassirSalamaNetwork (BOI15_net)C++17
0 / 100
5 ms12380 KiB
#include <bits/stdc++.h> using namespace std; const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1}; #define OVL(x,s) for(auto y:x) cout<<y<<s; cout<<"\n"; #ifdef IOI void dbg_out() { cout << endl; } template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); } #define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__); #else #define dbg(...) 1337; #endif #define endl "\n" #define pb push_back #define F first #define S second #define ll long long #define mod 1000000007 #define all(v) v.begin(),v.end() #define int long long const int MAXN=5e5+100; vector<int> v[MAXN]; vector<pair<int,int>> op; signed main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 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); } vector<int> lf; for(int i=1;i<=n;i++){ if(v[i].size()==1){ lf.pb(i); } } cout<<(lf.size()/2)+lf.size()%2<<endl; // OVL(lf," ") for(int i=0;i+1<lf.size();i+=2){ cout<<lf[i]<<" "<<lf[i+1]<<endl; } if(lf.size()%2){ cout<<lf[0]<<" "<<lf[lf.size()-1]<<endl; } }

Compilation message (stderr)

net.cpp: In function 'int main()':
net.cpp:40:16: 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]
   40 | for(int i=0;i+1<lf.size();i+=2){
      |             ~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...