結果

問題 No.806 木を道に
ユーザー sykwersykwer
提出日時 2019-03-22 21:37:42
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 1,195 bytes
コンパイル時間 1,030 ms
コンパイル使用メモリ 112,664 KB
実行使用メモリ 9,664 KB
最終ジャッジ日時 2023-10-19 06:36:26
合計ジャッジ時間 3,058 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 18 ms
4,992 KB
testcase_11 AC 16 ms
4,852 KB
testcase_12 AC 73 ms
8,752 KB
testcase_13 AC 52 ms
7,364 KB
testcase_14 AC 70 ms
8,512 KB
testcase_15 AC 75 ms
8,824 KB
testcase_16 AC 25 ms
5,524 KB
testcase_17 AC 63 ms
8,124 KB
testcase_18 AC 7 ms
4,348 KB
testcase_19 AC 19 ms
5,064 KB
testcase_20 AC 64 ms
8,128 KB
testcase_21 AC 35 ms
6,188 KB
testcase_22 AC 89 ms
9,664 KB
testcase_23 AC 89 ms
9,664 KB
testcase_24 AC 37 ms
6,560 KB
testcase_25 AC 56 ms
8,052 KB
testcase_26 AC 21 ms
5,336 KB
testcase_27 AC 67 ms
9,376 KB
testcase_28 AC 4 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    vector<int> table[N];
    for (int i = 0; i < N - 1; i++) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        table[s].push_back(t);
        table[t].push_back(s);
    }

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (table[i].size() == 1) cnt++;
    }

    cout << cnt - 2 << endl;

    return 0;
}
0