結果

問題 No.806 木を道に
ユーザー hamuhei4869hamuhei4869
提出日時 2019-03-22 21:43:13
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 503 bytes
コンパイル時間 1,170 ms
コンパイル使用メモリ 159,580 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-19 03:12:50
合計ジャッジ時間 2,739 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using LL = long long;
const LL LINF = 1e18;
class Edge{
public:
    LL to,from,value;
    Edge(LL t,LL f,LL c){
        to = t;
        from = f;
        value = c;
    }
};

int main(){
    int N;cin >> N;
    vector<int> vec(N);
    for(int a = 0;a < N-1;a++){
        int b,c;cin >> b >> c;
        vec.at(b-1)++;
        vec.at(c-1)++;
    }
    LL ans = 0;
    for(int a = 0;a < N;a++){
        ans += max(vec.at(a)-2,0);
    }
    cout<<ans<<endl;
}
0