結果

問題 No.806 木を道に
ユーザー ugis_progugis_prog
提出日時 2019-03-23 00:30:52
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 454 bytes
コンパイル時間 1,641 ms
コンパイル使用メモリ 72,872 KB
実行使用メモリ 9,004 KB
最終ジャッジ日時 2023-10-19 11:02:16
合計ジャッジ時間 3,543 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 17 ms
4,536 KB
testcase_11 AC 15 ms
4,348 KB
testcase_12 AC 70 ms
7,968 KB
testcase_13 AC 51 ms
6,648 KB
testcase_14 AC 66 ms
7,704 KB
testcase_15 AC 71 ms
7,968 KB
testcase_16 AC 24 ms
4,800 KB
testcase_17 AC 60 ms
7,176 KB
testcase_18 AC 7 ms
4,348 KB
testcase_19 AC 18 ms
4,536 KB
testcase_20 AC 61 ms
7,440 KB
testcase_21 AC 33 ms
5,592 KB
testcase_22 AC 84 ms
8,760 KB
testcase_23 AC 84 ms
8,760 KB
testcase_24 AC 36 ms
6,120 KB
testcase_25 AC 55 ms
7,704 KB
testcase_26 AC 20 ms
5,064 KB
testcase_27 AC 65 ms
9,004 KB
testcase_28 AC 3 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
using namespace std;

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