제출 #405185

#제출 시각아이디문제언어결과실행 시간메모리
405185T0p_Network (BOI15_net)C++17
0 / 100
1 ms204 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; }

컴파일 시 표준 에러 (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...