제출 #335635

#제출 시각아이디문제언어결과실행 시간메모리
335635JoshcNetwork (BOI15_net)C++11
100 / 100
542 ms52328 KiB
#include <cstdio> #include <vector> using namespace std; vector<int> edges[500001], l; void dfs(int v, int p) { if (edges[v].size() == 1) l.push_back(v); for (int u : edges[v]) { if (u != p) dfs(u, v); } } int main() { int n, a, b; scanf("%d", &n); for (int i=1; i<n; i++) { scanf("%d%d", &a, &b); edges[a].push_back(b); edges[b].push_back(a); } dfs(1, 0); int s = (l.size()+1)>>1; printf("%d\n", s); for (int i=0; i<s; i++) printf("%d %d\n", l[i], l[(i+s)%l.size()]); }

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

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