結果
問題 | No.806 木を道に |
ユーザー |
![]() |
提出日時 | 2019-03-22 21:32:19 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 19 ms / 2,000 ms |
コード長 | 285 bytes |
コンパイル時間 | 304 ms |
コンパイル使用メモリ | 27,648 KB |
最終ジャッジ日時 | 2025-01-06 23:44:57 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:6:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | int n; scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:8:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | int a, b; scanf("%d%d", &a, &b); | ~~~~~^~~~~~~~~~~~~~~~
ソースコード
#include <cstdio> int deg[100010]; int main() { int n; scanf("%d", &n); for(int i=1; i<n; ++i) { int a, b; scanf("%d%d", &a, &b); ++deg[--a]; ++deg[--b]; } int res=-2; for(int i=0; i<n; ++i) if (deg[i]==1) ++res; printf("%d\n", res); }