結果

問題 No.806 木を道に
ユーザー sigmanisigmani
提出日時 2022-02-19 18:15:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 339 bytes
コンパイル時間 1,620 ms
コンパイル使用メモリ 166,184 KB
実行使用メモリ 8,908 KB
最終ジャッジ日時 2023-09-11 20:50:12
合計ジャッジ時間 3,780 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,752 KB
testcase_01 AC 3 ms
5,792 KB
testcase_02 AC 4 ms
5,732 KB
testcase_03 AC 4 ms
5,740 KB
testcase_04 AC 3 ms
5,796 KB
testcase_05 AC 4 ms
5,968 KB
testcase_06 AC 3 ms
5,788 KB
testcase_07 AC 3 ms
5,800 KB
testcase_08 AC 3 ms
5,700 KB
testcase_09 AC 3 ms
5,748 KB
testcase_10 AC 17 ms
6,476 KB
testcase_11 AC 16 ms
6,416 KB
testcase_12 AC 63 ms
8,424 KB
testcase_13 AC 47 ms
7,864 KB
testcase_14 AC 62 ms
8,300 KB
testcase_15 AC 65 ms
8,680 KB
testcase_16 AC 24 ms
6,924 KB
testcase_17 AC 57 ms
8,076 KB
testcase_18 AC 8 ms
6,112 KB
testcase_19 AC 19 ms
6,464 KB
testcase_20 AC 57 ms
8,100 KB
testcase_21 AC 32 ms
7,024 KB
testcase_22 AC 78 ms
8,892 KB
testcase_23 AC 78 ms
8,908 KB
testcase_24 AC 36 ms
7,380 KB
testcase_25 AC 54 ms
8,232 KB
testcase_26 AC 20 ms
6,636 KB
testcase_27 AC 61 ms
8,900 KB
testcase_28 AC 5 ms
5,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
vector<int>G[101010];
int main(){
  int N;
  cin>>N;
  int V=N;
  int E=N-1;
  for(int i=1;i<=E;i++){
    int A,B;
    cin>>A>>B;
    G[A].push_back(B);
    G[B].push_back(A);
  }
  int answer=0;
  for(int i=1;i<=V;i++){
    if(G[i].size()>=3)answer=answer+G[i].size()-2;
  }
cout<<answer;


}
0