結果

問題 No.1424 Ultrapalindrome
ユーザー Example0911Example0911
提出日時 2021-03-12 21:46:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 727 bytes
コンパイル時間 2,193 ms
コンパイル使用メモリ 201,748 KB
実行使用メモリ 12,928 KB
最終ジャッジ日時 2024-04-22 12:36:32
合計ジャッジ時間 3,978 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,888 KB
testcase_01 AC 4 ms
5,888 KB
testcase_02 AC 3 ms
5,888 KB
testcase_03 AC 3 ms
5,888 KB
testcase_04 AC 3 ms
5,888 KB
testcase_05 WA -
testcase_06 AC 3 ms
5,760 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 34 ms
9,344 KB
testcase_10 AC 33 ms
9,216 KB
testcase_11 AC 24 ms
8,320 KB
testcase_12 AC 31 ms
9,088 KB
testcase_13 AC 10 ms
6,784 KB
testcase_14 AC 25 ms
8,516 KB
testcase_15 AC 3 ms
6,016 KB
testcase_16 AC 20 ms
7,936 KB
testcase_17 AC 24 ms
8,448 KB
testcase_18 AC 15 ms
7,424 KB
testcase_19 AC 25 ms
8,192 KB
testcase_20 AC 8 ms
6,400 KB
testcase_21 AC 20 ms
7,680 KB
testcase_22 AC 13 ms
7,040 KB
testcase_23 AC 5 ms
6,144 KB
testcase_24 AC 8 ms
6,400 KB
testcase_25 AC 7 ms
6,272 KB
testcase_26 AC 30 ms
8,576 KB
testcase_27 WA -
testcase_28 AC 34 ms
12,928 KB
testcase_29 WA -
testcase_30 AC 26 ms
10,256 KB
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

#define int long long
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = (1LL << 61);
ll mod = 1000000007;

int N;
vector<int>G[100010];
int depth[100010];
void dfs(int v, int p, int d) {
	depth[v] = d;
	for (auto nv : G[v]) {
		if (nv == p)continue;
		dfs(nv, v, d + 1);
	}
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> 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);
	}
	dfs(0, -1, 0);
	set<int>st;
	for (int i = 0; i < N; i++) {
		if (G[i].size() == 1) {
			st.insert(depth[i]);
		}
	}
	if (st.size() <= 2) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}
0