結果

問題 No.806 木を道に
ユーザー tottoripapertottoripaper
提出日時 2019-03-22 21:53:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 642 bytes
コンパイル時間 1,626 ms
コンパイル使用メモリ 169,352 KB
実行使用メモリ 9,152 KB
最終ジャッジ日時 2023-10-19 09:03:25
合計ジャッジ時間 3,183 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,992 KB
testcase_01 AC 4 ms
5,992 KB
testcase_02 AC 4 ms
5,996 KB
testcase_03 AC 4 ms
5,996 KB
testcase_04 AC 4 ms
5,996 KB
testcase_05 AC 4 ms
6,000 KB
testcase_06 AC 4 ms
6,000 KB
testcase_07 AC 4 ms
5,996 KB
testcase_08 AC 4 ms
5,992 KB
testcase_09 AC 4 ms
5,996 KB
testcase_10 AC 11 ms
6,692 KB
testcase_11 AC 11 ms
6,616 KB
testcase_12 AC 37 ms
8,672 KB
testcase_13 AC 27 ms
7,936 KB
testcase_14 AC 36 ms
8,540 KB
testcase_15 AC 38 ms
8,712 KB
testcase_16 AC 14 ms
6,972 KB
testcase_17 AC 31 ms
8,340 KB
testcase_18 AC 6 ms
6,256 KB
testcase_19 AC 11 ms
6,728 KB
testcase_20 AC 31 ms
8,344 KB
testcase_21 AC 19 ms
7,320 KB
testcase_22 AC 45 ms
9,152 KB
testcase_23 AC 46 ms
9,152 KB
testcase_24 AC 18 ms
7,644 KB
testcase_25 AC 26 ms
8,496 KB
testcase_26 AC 11 ms
6,932 KB
testcase_27 AC 28 ms
9,104 KB
testcase_28 AC 4 ms
6,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
std::vector<int> G[100100];

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> N;

    for(int i=1;i<N;++i){
        int a, b;
        std::cin >> a >> b;

        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    int cnt = 0;

    for(int i=1;i<=N;++i){
        cnt += std::max((int)G[i].size() - 2, 0);
    }

    std::cout << cnt << std::endl;
}
0