結果

問題 No.806 木を道に
ユーザー sawfish
提出日時 2022-10-24 11:00:29
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 451 bytes
コンパイル時間 1,544 ms
コンパイル使用メモリ 127,360 KB
実行使用メモリ 8,960 KB
最終ジャッジ日時 2024-07-02 14:37:57
合計ジャッジ時間 4,176 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

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