結果

問題 No.806 木を道に
ユーザー CleyLCleyL
提出日時 2022-05-02 18:34:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 328 bytes
コンパイル時間 613 ms
コンパイル使用メモリ 73,948 KB
実行使用メモリ 9,156 KB
最終ジャッジ日時 2023-09-14 15:21:52
合計ジャッジ時間 2,794 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 16 ms
4,536 KB
testcase_11 AC 15 ms
4,408 KB
testcase_12 AC 66 ms
8,040 KB
testcase_13 AC 48 ms
6,816 KB
testcase_14 AC 63 ms
7,860 KB
testcase_15 AC 68 ms
8,324 KB
testcase_16 AC 23 ms
5,232 KB
testcase_17 AC 58 ms
7,432 KB
testcase_18 AC 6 ms
4,380 KB
testcase_19 AC 17 ms
4,916 KB
testcase_20 AC 57 ms
7,524 KB
testcase_21 AC 31 ms
5,728 KB
testcase_22 AC 79 ms
9,140 KB
testcase_23 AC 78 ms
9,156 KB
testcase_24 AC 35 ms
6,316 KB
testcase_25 AC 52 ms
7,760 KB
testcase_26 AC 19 ms
5,016 KB
testcase_27 AC 61 ms
8,916 KB
testcase_28 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

int main(){
  int n;cin>>n;
  vector<int> B[n];
  for(int i = 0; n-1 > i; i++){
    int s,v;cin>>s>>v;
    B[--s].push_back(--v);
    B[v].push_back(s);
  }
  int ans = 0;
  for(int i = 0; n > i; i++){
    ans += max(0,(int)B[i].size()-2);
  }
  cout << ans << endl;
}
0