結果

問題 No.1424 Ultrapalindrome
ユーザー Example0911Example0911
提出日時 2021-03-12 22:19:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 827 bytes
コンパイル時間 2,176 ms
コンパイル使用メモリ 202,028 KB
実行使用メモリ 12,928 KB
最終ジャッジ日時 2024-04-22 13:20:32
合計ジャッジ時間 4,367 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,016 KB
testcase_01 AC 3 ms
6,016 KB
testcase_02 AC 4 ms
5,888 KB
testcase_03 AC 4 ms
5,888 KB
testcase_04 AC 4 ms
5,888 KB
testcase_05 AC 3 ms
6,016 KB
testcase_06 AC 3 ms
5,888 KB
testcase_07 AC 4 ms
6,016 KB
testcase_08 AC 3 ms
5,760 KB
testcase_09 AC 38 ms
9,344 KB
testcase_10 AC 40 ms
9,472 KB
testcase_11 AC 27 ms
8,448 KB
testcase_12 AC 36 ms
8,936 KB
testcase_13 AC 11 ms
6,912 KB
testcase_14 AC 30 ms
8,448 KB
testcase_15 AC 3 ms
5,888 KB
testcase_16 AC 23 ms
8,064 KB
testcase_17 AC 27 ms
8,448 KB
testcase_18 AC 80 ms
7,552 KB
testcase_19 AC 77 ms
8,064 KB
testcase_20 AC 13 ms
6,528 KB
testcase_21 AC 20 ms
7,296 KB
testcase_22 AC 21 ms
6,912 KB
testcase_23 AC 17 ms
6,144 KB
testcase_24 AC 7 ms
6,400 KB
testcase_25 AC 7 ms
6,144 KB
testcase_26 AC 33 ms
8,448 KB
testcase_27 WA -
testcase_28 AC 35 ms
12,928 KB
testcase_29 WA -
testcase_30 AC 197 ms
10,256 KB
testcase_31 AC 31 ms
10,132 KB
権限があれば一括ダウンロードができます

ソースコード

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);
	}
	for (int i = 0; i < min(200LL, N); i++) {
		if (G[i].size() == 1) {
			dfs(i, -1, 0);
			set<int>st;
			for (int j = 0; j < N; j++) {
				if (G[j].size() == 1) {
					st.insert(depth[j]);
				}
			}
			if (st.size() > 2) {
				cout << "No" << endl; return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}
0