제출 #74804

#제출 시각아이디문제언어결과실행 시간메모리
74804arman_ferdousNetwork (BOI15_net)C++17
0 / 100
36 ms12288 KiB
#include <bits/stdc++.h> using namespace std; const int N = 5e5+10; int n, d[N]; vector<int> g[N], leaf; int main() { scanf("%d", &n); for(int i = 1; i < n; i++) { int u, v; scanf("%d %d", &u, &v); g[u].push_back(v); g[v].push_back(u); d[u]++, d[v]++; } for(int i = 1; i <= n; i++) if(d[i] == 1) leaf.push_back(i); int sz = leaf.size(); printf("%d\n", (int)ceil(sz/2.)); for(int i = 0; i < sz; i+=2) { if(i+1 < sz) printf("%d %d\n", leaf[i], leaf[i+1]); else printf("%d %d\n", leaf[i], leaf[0]); } 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]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
net.cpp:11:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int u, v; scanf("%d %d", &u, &v);
             ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...