제출 #57859

#제출 시각아이디문제언어결과실행 시간메모리
57859IvanCNetwork (BOI15_net)C++17
0 / 100
3 ms728 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> ii; const int MAXN = 5*1e5 + 10; int grau[MAXN],N; vector<int> raizes; vector<ii> pares; int main(){ scanf("%d",&N); for(int i = 1;i<N;i++){ int a,b; scanf("%d %d",&a,&b); grau[a]++; grau[b]++; } for(int i = 1;i<=N;i++){ if(grau[i] == 1) raizes.push_back(i); } if(raizes.size() % 2 == 1) raizes.push_back(raizes[0]); while(!raizes.empty()){ int a = raizes.back(); raizes.pop_back(); int b = raizes.back(); raizes.pop_back(); pares.push_back(ii(a,b)); } printf("%d\n", (int)pares.size() ); for(ii davez : pares){ printf("%d %d\n",davez.first,davez.second); } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

net.cpp: In function 'int main()':
net.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&N);
  ~~~~~^~~~~~~~~
net.cpp:17:8: 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...