結果

問題 No.806 木を道に
ユーザー hipopohipopo
提出日時 2020-01-28 19:06:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 979 bytes
コンパイル時間 1,103 ms
コンパイル使用メモリ 112,660 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-13 20:51:21
合計ジャッジ時間 3,094 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 13 ms
4,348 KB
testcase_11 AC 11 ms
4,352 KB
testcase_12 AC 46 ms
4,348 KB
testcase_13 AC 33 ms
4,348 KB
testcase_14 AC 43 ms
4,348 KB
testcase_15 AC 46 ms
4,352 KB
testcase_16 AC 17 ms
4,348 KB
testcase_17 AC 40 ms
4,348 KB
testcase_18 AC 6 ms
4,352 KB
testcase_19 AC 13 ms
4,348 KB
testcase_20 AC 40 ms
4,348 KB
testcase_21 AC 23 ms
4,348 KB
testcase_22 AC 53 ms
4,352 KB
testcase_23 AC 53 ms
4,352 KB
testcase_24 AC 28 ms
4,348 KB
testcase_25 AC 42 ms
4,352 KB
testcase_26 AC 16 ms
4,348 KB
testcase_27 AC 51 ms
4,348 KB
testcase_28 AC 3 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class T>
istream& operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

int main() {
    int n;
    cin >> n;
    vector<int> deg(n);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        deg[a]++;
        deg[b]++;
    }

    int sum = 0;
    rep(i, n) sum += max(0, deg[i] - 2);
    cout << sum << endl;
}
0