Submission #305436

#TimeUsernameProblemLanguageResultExecution timeMemory
305436shahriarkhanNetwork (BOI15_net)C++14
0 / 100
1 ms384 KiB
#include<bits/stdc++.h> using namespace std ; int main() { int n ; scanf("%d",&n) ; int deg[n+1] = {0} ; for(int i = 1 ; i < n ; ++i) { int u , v ; scanf("%d%d",&u,&v) ; ++deg[u] , ++deg[v] ; } vector<int> ans ; for(int i = 1 ; i <= n ; ++i) { if(deg[i]==1) ans.push_back(i) ; } int p = ans.size() ; printf("%d\n",(p+1)/2) ; if(p%2) { printf("%d %d\n",ans[p-1],ans[p-2]) ; --p ; } for(int i = 0 ; i < p ; i += 2) { printf("%d %d\n",ans[i],ans[i+1]) ; } return 0 ; }

Compilation message (stderr)

net.cpp: In function 'int main()':
net.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |     scanf("%d",&n) ;
      |     ~~~~~^~~~~~~~~
net.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |         scanf("%d%d",&u,&v) ;
      |         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...