結果

問題 No.806 木を道に
ユーザー outlineoutline
提出日時 2020-03-28 00:21:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 427 bytes
コンパイル時間 1,927 ms
コンパイル使用メモリ 167,276 KB
実行使用メモリ 8,884 KB
最終ジャッジ日時 2023-08-30 17:07:49
合計ジャッジ時間 3,718 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,732 KB
testcase_01 AC 3 ms
5,608 KB
testcase_02 AC 3 ms
5,700 KB
testcase_03 AC 3 ms
5,984 KB
testcase_04 AC 4 ms
5,648 KB
testcase_05 AC 3 ms
5,852 KB
testcase_06 AC 3 ms
5,600 KB
testcase_07 AC 4 ms
5,660 KB
testcase_08 AC 3 ms
5,732 KB
testcase_09 AC 4 ms
5,664 KB
testcase_10 AC 18 ms
6,384 KB
testcase_11 AC 16 ms
6,416 KB
testcase_12 AC 61 ms
8,604 KB
testcase_13 AC 46 ms
7,588 KB
testcase_14 AC 59 ms
8,412 KB
testcase_15 AC 61 ms
8,496 KB
testcase_16 AC 23 ms
6,692 KB
testcase_17 AC 57 ms
7,956 KB
testcase_18 AC 8 ms
5,868 KB
testcase_19 AC 18 ms
6,396 KB
testcase_20 AC 56 ms
7,944 KB
testcase_21 AC 31 ms
7,100 KB
testcase_22 AC 72 ms
8,884 KB
testcase_23 AC 73 ms
8,844 KB
testcase_24 AC 36 ms
7,588 KB
testcase_25 AC 53 ms
8,116 KB
testcase_26 AC 20 ms
6,564 KB
testcase_27 AC 61 ms
8,880 KB
testcase_28 AC 5 ms
6,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
vector<int> graph[100005];
int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n - 1; ++i){
        int a, b;
        cin >> a >> b;
        a = a - 1;
        b = b - 1;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    int64_t ans = 0;
    for(int i = 0; i < n; ++i){
        ans += max(0, (int)graph[i].size() - 2);
    }
    cout << ans << endl;
}
0