Submission #42651

#TimeUsernameProblemLanguageResultExecution timeMemory
42651XmtosXNetwork (BOI15_net)C++14
0 / 100
11 ms12396 KiB
#include <bits/stdc++.h> using namespace std; int n,last; queue <int> q; vector <int> v[500005]; int main() { scanf("%d",&n); for (int i=0;i<n-1;i++) { int a,b; scanf("%d%d",&a,&b); v[a].push_back(b); v[b].push_back(a); } for (int i=1;i<=n;i++) { if (v[i].size()==1) q.push(i); } printf("%d\n",q.size()/2+(q.size())%2); while (q.size()>1) { last=q.front(); printf("%d ",q.front()); q.pop(); printf("%d\n",q.front()); q.pop(); } if (!q.empty()) printf("%d %d\n",q.front(),last); return 0; }

Compilation message (stderr)

net.cpp: In function 'int main()':
net.cpp:21:42: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::queue<int>::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d\n",q.size()/2+(q.size())%2);
                                          ^
net.cpp:8:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
net.cpp:12:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&a,&b);
                            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...