結果

問題 No.806 木を道に
ユーザー tactac
提出日時 2019-07-13 14:23:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 703 bytes
コンパイル時間 1,556 ms
コンパイル使用メモリ 168,656 KB
実行使用メモリ 8,960 KB
最終ジャッジ日時 2024-05-01 16:37:25
合計ジャッジ時間 3,594 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 16 ms
5,376 KB
testcase_11 AC 14 ms
5,376 KB
testcase_12 AC 58 ms
8,064 KB
testcase_13 AC 43 ms
6,944 KB
testcase_14 AC 56 ms
8,064 KB
testcase_15 AC 63 ms
8,192 KB
testcase_16 AC 22 ms
5,376 KB
testcase_17 AC 53 ms
7,552 KB
testcase_18 AC 6 ms
5,376 KB
testcase_19 AC 15 ms
5,376 KB
testcase_20 AC 51 ms
7,552 KB
testcase_21 AC 29 ms
5,888 KB
testcase_22 AC 72 ms
8,960 KB
testcase_23 AC 70 ms
8,960 KB
testcase_24 AC 37 ms
6,400 KB
testcase_25 AC 53 ms
7,680 KB
testcase_26 AC 19 ms
5,376 KB
testcase_27 AC 62 ms
8,896 KB
testcase_28 AC 4 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
int main() {
    int n; cin >> n;
    vector<int> v[n];
    rep(i, n - 1) {
        int a, b; cin >> a >> b; a--; b--;
        v[a].eb(b);
        v[b].eb(a);
    }
    int sum = 0;
    rep(i, n) {
        if (SZ(v[i]) > 2) sum += SZ(v[i]) - 2;
    }
    out(sum);
}

0