結果
問題 | No.806 木を道に |
ユーザー |
![]() |
提出日時 | 2019-10-23 22:50:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 95 ms / 2,000 ms |
コード長 | 431 bytes |
コンパイル時間 | 1,295 ms |
コンパイル使用メモリ | 173,116 KB |
実行使用メモリ | 8,192 KB |
最終ジャッジ日時 | 2024-07-07 05:59:43 |
合計ジャッジ時間 | 3,423 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef pair<int,int> P; int main(){ int n; cin >> n; map<int,int> mp; rep(i,n-1) { int a, b; cin >> a >> b; a--; b--; mp[a]++; mp[b]++; } int res = 0; for (auto p : mp) { if (p.second > 2) res += p.second - 2; } cout << res << endl; return 0; }