結果

問題 No.1719 Tree and Permutation
ユーザー square1001square1001
提出日時 2021-10-22 22:24:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 509 bytes
コンパイル時間 759 ms
コンパイル使用メモリ 79,636 KB
実行使用メモリ 9,272 KB
最終ジャッジ日時 2023-10-24 13:40:39
合計ジャッジ時間 3,790 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 <queue>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	int Q;
	cin >> Q;
	while (Q--) {
		int N;
		cin >> N;
		vector<vector<int> > G(N);
		for (int i = 0; i < N - 1; ++i) {
			int a, b;
			cin >> a >> b; --a, --b;
			G[a].push_back(b);
			G[b].push_back(a);
		}
		bool answer = false;
		for (int i = 0; i < N; ++i) {
			if (G[i].size() >= 3) {
				answer = true;
			}
		}
		cout << (answer ? "Yes" : "No") << endl;
	}
	return 0;
}
0