結果

問題 No.1719 Tree and Permutation
ユーザー 👑 NachiaNachia
提出日時 2021-10-22 21:53:38
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 735 bytes
コンパイル時間 990 ms
コンパイル使用メモリ 78,900 KB
実行使用メモリ 9,172 KB
最終ジャッジ日時 2023-10-24 13:00:22
合計ジャッジ時間 2,787 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 87 ms
4,348 KB
testcase_02 AC 120 ms
4,348 KB
testcase_03 AC 187 ms
9,172 KB
testcase_04 AC 169 ms
8,204 KB
testcase_05 AC 181 ms
8,868 KB
testcase_06 AC 169 ms
8,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(n); i++)


int main(){
  int T; cin >> T;
  while(T--){
    int N; cin >> N;
    vector<vector<int>> E(N);
    rep(i,N-1){
      int u,v; cin >> u >> v; u--; v--;
      E[u].push_back(v);
      E[v].push_back(u);
    }
    
    int leaf_count = 0;
    rep(i,N) if(E[i].size() == 1) leaf_count += 1;
    if(leaf_count * 2 < N) cout << "No\n";
    else cout << "Yes\n";
  }
  return 0;
}




struct ios_do_not_sync {
    ios_do_not_sync() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    }
} ios_do_not_sync_instance;
0