結果

問題 No.806 木を道に
ユーザー ceni1055ceni1055
提出日時 2019-03-22 21:49:25
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 401 bytes
コンパイル時間 1,782 ms
コンパイル使用メモリ 176,104 KB
実行使用メモリ 8,840 KB
最終ジャッジ日時 2023-10-19 07:47:37
合計ジャッジ時間 4,184 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 23 ms
4,672 KB
testcase_11 AC 21 ms
4,560 KB
testcase_12 AC 108 ms
8,048 KB
testcase_13 AC 73 ms
6,728 KB
testcase_14 AC 101 ms
7,784 KB
testcase_15 AC 108 ms
8,048 KB
testcase_16 AC 33 ms
5,088 KB
testcase_17 AC 91 ms
7,256 KB
testcase_18 AC 9 ms
4,348 KB
testcase_19 AC 25 ms
4,724 KB
testcase_20 AC 93 ms
7,256 KB
testcase_21 AC 47 ms
5,672 KB
testcase_22 AC 136 ms
8,840 KB
testcase_23 AC 134 ms
8,840 KB
testcase_24 AC 50 ms
6,200 KB
testcase_25 AC 77 ms
7,784 KB
testcase_26 AC 26 ms
5,044 KB
testcase_27 AC 91 ms
8,576 KB
testcase_28 AC 4 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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> cnt;
  for (int i = 0; i < n; i++)
  {
    int a, b;
    cin >> a >> b;
    cnt[a]++;
    cnt[b]++;
    edge[i] = {a, b};
  }
  int ans = 0;
  for (pair<int, int> i : cnt)
    ans += max(0, i.second - 2);
  cout << ans << endl;

  return 0;
}
0