結果

問題 No.806 木を道に
コンテスト
ユーザー ceni1055
提出日時 2019-03-22 21:41:23
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 497 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 996 ms
コンパイル使用メモリ 189,720 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2026-08-30 18:04:03
合計ジャッジ時間 3,750 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 3 WA * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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;
}
0