結果

問題 No.806 木を道に
ユーザー kyunakyuna
提出日時 2019-07-20 00:35:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 418 bytes
コンパイル時間 779 ms
コンパイル使用メモリ 73,176 KB
実行使用メモリ 8,860 KB
最終ジャッジ日時 2023-08-27 02:04:40
合計ジャッジ時間 5,312 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 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 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 16 ms
4,384 KB
testcase_11 AC 15 ms
4,376 KB
testcase_12 AC 69 ms
7,856 KB
testcase_13 AC 48 ms
6,384 KB
testcase_14 AC 64 ms
7,452 KB
testcase_15 AC 70 ms
7,704 KB
testcase_16 AC 24 ms
4,636 KB
testcase_17 AC 60 ms
7,072 KB
testcase_18 AC 7 ms
4,376 KB
testcase_19 AC 17 ms
4,380 KB
testcase_20 AC 58 ms
6,936 KB
testcase_21 AC 32 ms
5,616 KB
testcase_22 AC 85 ms
8,612 KB
testcase_23 AC 80 ms
8,512 KB
testcase_24 AC 35 ms
6,012 KB
testcase_25 AC 52 ms
7,632 KB
testcase_26 AC 19 ms
4,916 KB
testcase_27 AC 62 ms
8,860 KB
testcase_28 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n; cin >> n;
    vector<vector<int>> g(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b; cin >> a >> b; a--, b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) ans += max(0, (int)g[i].size() - 2);
    cout << ans << endl;
    return 0;
}
0