結果

問題 No.806 木を道に
ユーザー NOSSNOSS
提出日時 2019-03-22 21:31:29
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 847 bytes
コンパイル時間 1,600 ms
コンパイル使用メモリ 165,796 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-19 02:52:06
合計ジャッジ時間 3,192 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<int ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()



int main() {
    int n, deg[MAX_N]{}, cnt = 0;
    cin >> n;
    REP(i,n-1){
        int a, b;
        cin >> a >> b;
        deg[--a]++;
        deg[--b]++;
    }
    REP(i,n){
        if(deg[i]==1)cnt++;
    }
    cout << cnt - 2 << endl;
    return 0;
}
0