結果

問題 No.806 木を道に
ユーザー aaaaaaiuaaaaaaiu
提出日時 2019-08-22 02:15:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 407 bytes
コンパイル時間 2,196 ms
コンパイル使用メモリ 196,208 KB
実行使用メモリ 9,088 KB
最終ジャッジ日時 2024-04-19 05:35:50
合計ジャッジ時間 4,395 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 18 ms
5,376 KB
testcase_11 AC 13 ms
5,376 KB
testcase_12 AC 73 ms
8,192 KB
testcase_13 AC 42 ms
6,912 KB
testcase_14 AC 61 ms
8,064 KB
testcase_15 AC 72 ms
8,320 KB
testcase_16 AC 21 ms
5,376 KB
testcase_17 AC 58 ms
7,680 KB
testcase_18 AC 6 ms
5,376 KB
testcase_19 AC 16 ms
5,376 KB
testcase_20 AC 56 ms
7,680 KB
testcase_21 AC 29 ms
5,760 KB
testcase_22 AC 75 ms
9,088 KB
testcase_23 AC 79 ms
8,960 KB
testcase_24 AC 33 ms
6,528 KB
testcase_25 AC 50 ms
7,808 KB
testcase_26 AC 19 ms
5,376 KB
testcase_27 AC 62 ms
9,004 KB
testcase_28 AC 3 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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