結果

問題 No.806 木を道に
ユーザー eQeeQe
提出日時 2019-04-06 11:51:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 829 bytes
コンパイル時間 1,525 ms
コンパイル使用メモリ 167,796 KB
実行使用メモリ 9,396 KB
最終ジャッジ日時 2023-09-05 23:13:19
合計ジャッジ時間 5,674 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,700 KB
testcase_01 AC 4 ms
5,764 KB
testcase_02 AC 4 ms
5,872 KB
testcase_03 AC 4 ms
5,872 KB
testcase_04 AC 3 ms
5,704 KB
testcase_05 AC 3 ms
5,756 KB
testcase_06 AC 3 ms
5,740 KB
testcase_07 AC 4 ms
5,680 KB
testcase_08 AC 3 ms
5,736 KB
testcase_09 AC 3 ms
5,684 KB
testcase_10 AC 18 ms
6,500 KB
testcase_11 AC 16 ms
6,480 KB
testcase_12 AC 68 ms
8,772 KB
testcase_13 AC 48 ms
7,928 KB
testcase_14 AC 65 ms
8,744 KB
testcase_15 AC 69 ms
8,824 KB
testcase_16 AC 26 ms
6,992 KB
testcase_17 AC 59 ms
8,452 KB
testcase_18 AC 9 ms
6,188 KB
testcase_19 AC 19 ms
6,540 KB
testcase_20 AC 61 ms
8,388 KB
testcase_21 AC 34 ms
7,192 KB
testcase_22 AC 80 ms
9,328 KB
testcase_23 AC 79 ms
9,384 KB
testcase_24 AC 36 ms
7,336 KB
testcase_25 AC 53 ms
8,268 KB
testcase_26 AC 20 ms
6,616 KB
testcase_27 AC 63 ms
9,396 KB
testcase_28 AC 5 ms
6,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b ? a:b;}
ll min(ll a, ll b) {return a<b ? a:b;}

ll N;
vector<ll> g[MAX];

int main() {
    cin >> N;
    ll i;
    
    for(i=0; i<N-1; i++) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    
    ll ans=0;
    for(i=0; i<N; i++)
        ans+=max(0, g[i].size()-2);
    
    pt(ans);
    
}
0