結果
問題 | No.806 木を道に |
ユーザー | neko_the_shadow |
提出日時 | 2019-03-22 21:54:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 56 ms / 2,000 ms |
コード長 | 395 bytes |
コンパイル時間 | 598 ms |
コンパイル使用メモリ | 74,992 KB |
最終ジャッジ日時 | 2025-01-06 23:49:24 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
ソースコード
#include<iostream> #include<vector> #include<algorithm> int main() { int n; std::cin >> n; std::vector<int> c(n, 0); for (int i = 0; i < n - 1; i++) { int a, b; std::cin >> a >> b; a--; b--; c[a]++; c[b]++; } int x = std::count_if(c.begin(), c.end(), [&](int v){ return v == 1; }); std::cout << x - 2 << std::endl; }