結果

問題 No.806 木を道に
ユーザー pekempeypekempey
提出日時 2019-03-22 23:15:21
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 435 bytes
コンパイル時間 726 ms
コンパイル使用メモリ 71,832 KB
実行使用メモリ 9,184 KB
最終ジャッジ日時 2023-10-19 10:30:30
合計ジャッジ時間 2,735 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,028 KB
testcase_01 AC 4 ms
6,028 KB
testcase_02 AC 4 ms
6,032 KB
testcase_03 AC 4 ms
6,032 KB
testcase_04 AC 4 ms
6,028 KB
testcase_05 AC 4 ms
6,032 KB
testcase_06 AC 4 ms
6,032 KB
testcase_07 AC 4 ms
6,028 KB
testcase_08 AC 4 ms
6,028 KB
testcase_09 AC 4 ms
6,032 KB
testcase_10 AC 19 ms
6,724 KB
testcase_11 AC 17 ms
6,648 KB
testcase_12 AC 69 ms
8,704 KB
testcase_13 AC 50 ms
7,968 KB
testcase_14 AC 66 ms
8,572 KB
testcase_15 AC 72 ms
8,744 KB
testcase_16 AC 25 ms
7,004 KB
testcase_17 AC 61 ms
8,372 KB
testcase_18 AC 9 ms
6,288 KB
testcase_19 AC 20 ms
6,760 KB
testcase_20 AC 60 ms
8,376 KB
testcase_21 AC 34 ms
7,352 KB
testcase_22 AC 83 ms
9,184 KB
testcase_23 AC 83 ms
9,184 KB
testcase_24 AC 39 ms
7,676 KB
testcase_25 AC 56 ms
8,528 KB
testcase_26 AC 22 ms
6,964 KB
testcase_27 AC 65 ms
9,184 KB
testcase_28 AC 5 ms
6,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

vector<int> G[100000];

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (G[i].size() >= 3) {
      ans += G[i].size() - 2;
    }
  }
  cout << ans << '\n';
}
0