Submission #146829

#TimeUsernameProblemLanguageResultExecution timeMemory
146829muhammad_hokimiyonNetwork (BOI15_net)C++14
0 / 100
9 ms5240 KiB
#include <bits/stdc++.h> //#pragma GCC optimize("Ofast") #define LL long long #define se second #define fi first using namespace std; const int N = 2e5 + 7; const int mod = 1e9 + 7; const int B = sqrt(N); int n; bool used[N]; vector < int > v[N]; vector < int > ans; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); //freopen( "input.txt" , "r" , stdin ); //freopen( "output.txt" , "w" , stdout ); cin >> n; for( int i = 1; i < n; i++ ){ int x,y; cin >> x >> y; v[x].push_back(y); v[y].push_back(x); } int x = 1; for( int i = 1; i <= n; i++ ){ if( v[i].size() == 1 ){ ans.push_back(i); } } int k = ans.size() / 2; cout << ( (int)ans.size() + 1 ) / 2 << "\n"; for( int i = 0; i < ( ans.size() + 1) / 2; i++ ){ cout << ans[i] << " " << ans[ (i + k) ] << "\n"; } }

Compilation message (stderr)

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