結果

問題 No.806 木を道に
ユーザー hiroahiroa
提出日時 2019-05-03 09:13:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 454 bytes
コンパイル時間 1,592 ms
コンパイル使用メモリ 166,816 KB
実行使用メモリ 9,084 KB
最終ジャッジ日時 2023-08-30 05:04:23
合計ジャッジ時間 4,284 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,724 KB
testcase_01 AC 4 ms
5,980 KB
testcase_02 AC 3 ms
5,680 KB
testcase_03 AC 4 ms
5,796 KB
testcase_04 AC 4 ms
5,668 KB
testcase_05 AC 4 ms
5,760 KB
testcase_06 AC 3 ms
5,828 KB
testcase_07 AC 3 ms
5,680 KB
testcase_08 AC 3 ms
5,792 KB
testcase_09 AC 4 ms
5,720 KB
testcase_10 AC 18 ms
6,436 KB
testcase_11 AC 17 ms
6,304 KB
testcase_12 AC 69 ms
8,472 KB
testcase_13 AC 49 ms
7,692 KB
testcase_14 AC 65 ms
8,264 KB
testcase_15 AC 69 ms
8,456 KB
testcase_16 AC 25 ms
6,640 KB
testcase_17 AC 59 ms
8,016 KB
testcase_18 AC 9 ms
5,984 KB
testcase_19 AC 19 ms
6,472 KB
testcase_20 AC 61 ms
8,012 KB
testcase_21 AC 34 ms
7,056 KB
testcase_22 AC 83 ms
9,084 KB
testcase_23 AC 81 ms
9,004 KB
testcase_24 AC 36 ms
7,312 KB
testcase_25 AC 53 ms
8,428 KB
testcase_26 AC 21 ms
6,816 KB
testcase_27 AC 62 ms
8,772 KB
testcase_28 AC 5 ms
5,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9

const int MAX_N=100010;
vector<int> G[MAX_N];

int main(){
    int N;
    cin>>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++){
        ans+=max(0,(int)G[i].size()-2);
    }
    cout<<ans<<endl;
    
}
0