Submission #405182

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

Compilation message (stderr)

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