結果

問題 No.806 木を道に
ユーザー NacoNaco
提出日時 2019-07-01 15:34:38
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 375 bytes
コンパイル時間 585 ms
コンパイル使用メモリ 65,968 KB
実行使用メモリ 8,204 KB
最終ジャッジ日時 2023-09-23 02:39:36
合計ジャッジ時間 3,130 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 22 ms
4,384 KB
testcase_11 AC 19 ms
4,440 KB
testcase_12 AC 94 ms
7,356 KB
testcase_13 AC 66 ms
6,204 KB
testcase_14 AC 90 ms
7,176 KB
testcase_15 AC 97 ms
7,408 KB
testcase_16 AC 31 ms
4,792 KB
testcase_17 AC 81 ms
6,860 KB
testcase_18 AC 9 ms
4,376 KB
testcase_19 AC 23 ms
4,460 KB
testcase_20 AC 81 ms
6,860 KB
testcase_21 AC 43 ms
5,284 KB
testcase_22 AC 114 ms
8,004 KB
testcase_23 AC 116 ms
8,204 KB
testcase_24 AC 45 ms
5,784 KB
testcase_25 AC 71 ms
7,156 KB
testcase_26 AC 23 ms
4,836 KB
testcase_27 AC 84 ms
7,896 KB
testcase_28 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<map>
using namespace std;

int main(){
    int N;
    cin >> N;
    map<int,int> m;
    for(int i=1;i<N;i++){
        int a,b;
        cin >> a >> b;
        m[a]++;m[b]++;
    }
    long long ans=0;
    for(auto it=m.begin();it!=m.end();it++){
        if(it->second-2>=0){
            ans+=it->second-2;
        }
    }
    cout << ans << endl;
}
0