結果

問題 No.806 木を道に
ユーザー beetbeet
提出日時 2019-03-22 21:33:13
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 532 bytes
コンパイル時間 4,129 ms
コンパイル使用メモリ 205,504 KB
実行使用メモリ 9,316 KB
最終ジャッジ日時 2023-10-19 06:32:37
合計ジャッジ時間 4,180 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 18 ms
4,564 KB
testcase_11 AC 17 ms
4,348 KB
testcase_12 AC 73 ms
8,260 KB
testcase_13 AC 52 ms
6,940 KB
testcase_14 AC 69 ms
7,996 KB
testcase_15 AC 74 ms
8,524 KB
testcase_16 AC 25 ms
5,092 KB
testcase_17 AC 64 ms
7,732 KB
testcase_18 AC 8 ms
4,348 KB
testcase_19 AC 20 ms
4,564 KB
testcase_20 AC 64 ms
7,732 KB
testcase_21 AC 36 ms
5,884 KB
testcase_22 AC 87 ms
9,316 KB
testcase_23 AC 85 ms
9,316 KB
testcase_24 AC 37 ms
6,148 KB
testcase_25 AC 56 ms
7,732 KB
testcase_26 AC 21 ms
5,256 KB
testcase_27 AC 67 ms
9,292 KB
testcase_28 AC 3 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<vector<Int> > G(n);
  for(Int i=1;i<n;i++){
    Int x,y;
    cin>>x>>y;
    x--;y--;
    G[x].emplace_back(y);
    G[y].emplace_back(x);
  }
  Int ans=0;
  for(Int i=0;i<n;i++) ans+=max(0LL,(Int)G[i].size()-2);
  cout<<ans<<endl;
  return 0;
}
0