結果

問題 No.1719 Tree and Permutation
ユーザー vjudge1
提出日時 2025-05-13 12:16:19
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 811 bytes
コンパイル時間 11,290 ms
コンパイル使用メモリ 221,676 KB
実行使用メモリ 10,268 KB
最終ジャッジ日時 2025-05-13 12:16:33
合計ジャッジ時間 8,928 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<ext/pb_ds/priority_queue.hpp>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define pii pair<int,int>
const double PI=acos(-1.0);
template <class Miaowu>
inline void in(Miaowu &x){
    char c;x=0;bool f=0;
    for(c=getchar();c<'0'||c>'9';c=getchar())f|=c=='-';
    for(;c>='0'&&c<='9';c=getchar())x=(x<<1)+(x<<3)+(c^48);
    x=f?-x:x;
}
const int N=1e5+5;
vector<int>g[N];
int T,n,p[N];
int main(){
	for(cin>>T;T;T--){
		in(n);
		for(int i=1;i<=n;i++)g[i].clear();
		for(int i=1,u,v;i<n;i++){
			in(u),in(v);
			g[u].push_back(v),g[v].push_back(u);
		}
		vector<int>vc1,vc2;
		for(int i=1;i<=n;i++){
			if(g[i].size()==1)vc1.push_back(i);
			else vc2.push_back(i);
		}
		puts(vc1.size()>=vc2.size()?"Yes":"No");
	}
	return 0;
}
0