結果
問題 | No.806 木を道に |
ユーザー |
![]() |
提出日時 | 2019-03-22 23:15:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 115 ms / 2,000 ms |
コード長 | 358 bytes |
コンパイル時間 | 1,509 ms |
コンパイル使用メモリ | 173,304 KB |
実行使用メモリ | 8,192 KB |
最終ジャッジ日時 | 2024-09-19 06:51:30 |
合計ジャッジ時間 | 3,596 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
ソースコード
#include "bits/stdc++.h" using namespace std; void solve() { int n, ans = 0; cin >> n; map<int, int> mp; for (int x = 0; x < n - 1; x++) { int a, b; cin >> a >> b; mp[a]++; mp[b]++; } for (auto p : mp) { ans += max(p.second - 2, 0); } cout << ans << endl; } int main(void) { solve(); //cout << "yui(*-v・)yui" << endl; return 0; }