結果
問題 | No.806 木を道に |
ユーザー |
![]() |
提出日時 | 2019-03-22 21:41:23 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 497 bytes |
コンパイル時間 | 1,715 ms |
コンパイル使用メモリ | 175,624 KB |
実行使用メモリ | 11,520 KB |
最終ジャッジ日時 | 2024-09-19 03:11:32 |
合計ジャッジ時間 | 3,954 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 3 WA * 24 |
ソースコード
#include <bits/stdc++.h> #include <assert.h> using namespace std; int main() { int n; cin >> n; n--; vector<pair<int, int>> edge(n); map<int, int> aCnt,bCnt; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; if(b<a)swap(a,b); aCnt[a]++; bCnt[b]++; edge[i] = {a, b}; } int ans = 0; for (pair<int, int> i : aCnt) ans += max(0, i.second - 2); for (pair<int, int> i : bCnt) ans += max(0, i.second - 2); cout << ans << endl; return 0; }