結果

問題 No.806 木を道に
ユーザー sawfishsawfish
提出日時 2022-10-24 11:00:29
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 451 bytes
コンパイル時間 6,018 ms
コンパイル使用メモリ 90,188 KB
実行使用メモリ 9,004 KB
最終ジャッジ日時 2023-09-15 10:58:20
合計ジャッジ時間 11,081 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 17 ms
4,616 KB
testcase_11 AC 15 ms
4,580 KB
testcase_12 AC 70 ms
8,128 KB
testcase_13 AC 49 ms
6,880 KB
testcase_14 AC 66 ms
7,936 KB
testcase_15 AC 70 ms
8,276 KB
testcase_16 AC 24 ms
5,100 KB
testcase_17 AC 61 ms
7,588 KB
testcase_18 AC 7 ms
4,380 KB
testcase_19 AC 18 ms
4,816 KB
testcase_20 AC 61 ms
7,588 KB
testcase_21 AC 32 ms
5,772 KB
testcase_22 AC 80 ms
9,004 KB
testcase_23 AC 82 ms
8,992 KB
testcase_24 AC 36 ms
6,396 KB
testcase_25 AC 55 ms
7,776 KB
testcase_26 AC 20 ms
5,188 KB
testcase_27 AC 65 ms
8,848 KB
testcase_28 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int N;
    cin >> N;

    vector<int> G[N + 1];
    int a, b;
    for (int i = 0; i < N - 1; i++) {
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    map<int, int> D;
    for (int i = 1; i <= N; i++) {
        D[G[i].size()]++;
    }

    cout << D[1] - 2 << endl;
}
0