結果
| 問題 | No.1719 Tree and Permutation | 
| コンテスト | |
| ユーザー |  Nachia | 
| 提出日時 | 2021-10-22 21:53:38 | 
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 218 ms / 2,000 ms | 
| コード長 | 735 bytes | 
| コンパイル時間 | 2,727 ms | 
| コンパイル使用メモリ | 106,724 KB | 
| 最終ジャッジ日時 | 2025-01-25 03:32:23 | 
| ジャッジサーバーID (参考情報) | judge2 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 6 | 
ソースコード
#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;
            
            
            
        