結果

問題 No.806 木を道に
ユーザー graythunder1graythunder1
提出日時 2019-06-27 16:02:55
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 615 bytes
コンパイル時間 1,981 ms
コンパイル使用メモリ 71,056 KB
実行使用メモリ 9,244 KB
最終ジャッジ日時 2023-09-10 10:22:47
合計ジャッジ時間 3,311 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 17 ms
4,488 KB
testcase_11 AC 15 ms
4,384 KB
testcase_12 AC 66 ms
8,184 KB
testcase_13 AC 46 ms
6,692 KB
testcase_14 AC 62 ms
7,712 KB
testcase_15 AC 68 ms
8,124 KB
testcase_16 AC 23 ms
4,848 KB
testcase_17 AC 57 ms
7,480 KB
testcase_18 AC 7 ms
4,380 KB
testcase_19 AC 17 ms
4,376 KB
testcase_20 AC 58 ms
7,596 KB
testcase_21 AC 31 ms
5,392 KB
testcase_22 AC 78 ms
9,112 KB
testcase_23 AC 78 ms
9,244 KB
testcase_24 AC 35 ms
5,940 KB
testcase_25 AC 53 ms
7,524 KB
testcase_26 AC 20 ms
5,124 KB
testcase_27 AC 63 ms
9,012 KB
testcase_28 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

int main(){
  ll N;
  cin >> N;
  vector<vector<ll> > edges(N);
  rep(i, N-1){
    ll a, b;
    cin >> a >> b;
    edges[a-1].push_back(b-1);
    edges[b-1].push_back(a-1);
  }

  ll ans = 0;
  for(auto it = edges.begin(); it != edges.end(); ++it){
    if((*it).size() >= 2) ans += (*it).size() - 2;
  }
  cout << ans << endl;
  return 0;
}
0