結果

問題 No.806 木を道に
ユーザー kappybarkappybar
提出日時 2020-04-10 16:33:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 568 bytes
コンパイル時間 1,578 ms
コンパイル使用メモリ 168,768 KB
実行使用メモリ 8,988 KB
最終ジャッジ日時 2023-10-13 07:29:20
合計ジャッジ時間 4,257 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,416 KB
testcase_01 AC 3 ms
5,476 KB
testcase_02 AC 3 ms
5,296 KB
testcase_03 AC 4 ms
5,284 KB
testcase_04 AC 3 ms
5,304 KB
testcase_05 AC 3 ms
5,236 KB
testcase_06 AC 4 ms
5,300 KB
testcase_07 AC 3 ms
5,248 KB
testcase_08 AC 4 ms
5,492 KB
testcase_09 AC 3 ms
5,280 KB
testcase_10 AC 18 ms
5,884 KB
testcase_11 AC 15 ms
5,880 KB
testcase_12 AC 64 ms
8,048 KB
testcase_13 AC 47 ms
7,212 KB
testcase_14 AC 63 ms
7,848 KB
testcase_15 AC 66 ms
8,320 KB
testcase_16 AC 25 ms
6,472 KB
testcase_17 AC 58 ms
7,900 KB
testcase_18 AC 8 ms
5,700 KB
testcase_19 AC 19 ms
6,208 KB
testcase_20 AC 57 ms
7,736 KB
testcase_21 AC 32 ms
6,724 KB
testcase_22 AC 79 ms
8,524 KB
testcase_23 AC 80 ms
8,540 KB
testcase_24 AC 37 ms
6,960 KB
testcase_25 AC 53 ms
7,792 KB
testcase_26 AC 21 ms
6,484 KB
testcase_27 AC 62 ms
8,988 KB
testcase_28 AC 5 ms
5,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll =  long long ;
using P = pair<ll,ll> ;
const ll INF = 1e18;
const int MOD = 1000000007;
int n = 100005;
vector<vector<int>> tree(n,vector<int>());

int main(){
    cin >> n;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        --a;--b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }   
    int ans = 0;
    rep(i,n){
        if(tree[i].size() == 1) continue;
        else ans += tree[i].size() - 2;
    }
    cout << ans << endl;
    return 0;
}
0