結果

問題 No.1719 Tree and Permutation
ユーザー 👑 NachiaNachia
提出日時 2021-10-22 21:40:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 773 bytes
コンパイル時間 663 ms
コンパイル使用メモリ 79,280 KB
実行使用メモリ 9,176 KB
最終ジャッジ日時 2023-10-24 12:39:50
合計ジャッジ時間 2,370 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
権限があれば一括ダウンロードができます

ソースコード

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);
    }

    if(N%2 == 0){ cout << "Yes\n"; continue; }
    
    bool is_line = true;
    rep(i,N) if(E[i].size() >= 3) is_line = false;
    if(is_line) 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