{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"MD","content":"八分熟算法是图上的一种搜索算法,它的描述如下:\n\u003e 1. 考虑 $n$ 个点的无向图,点的编号从 $1$ 到 $n$。\n\u003e 2. 初始化一个队列,里面只有 $1$ 号点;标记 $1$ 号点。\n\u003e 3. 从队首弹出一个点 $u$,输出 $u$ 的编号。\n\u003e 4. 以任意顺序遍历 $u$ 的所有邻接点,若当前所遍历的邻接点没有被标记过,那么标记这个点并放入队尾。\n\u003e 5. 若队伍为空则停止,否则回到第三步。\n\n显然上述算法的输出结果不一定唯一。现在给定一棵无根树,以及 $1,2,\\cdots,n$ 的一个排列,问该排列是否可以作为八分熟算法的一个合法输出。"}},{"title":"Input","value":{"format":"MD","content":"第一行包含一个整数 $1 \\leq n \\leq 2 \\cdot 10^5$,表示点数。\n\n随后 $n - 1$ 行每行包含两个数 $1 \\leq u, v \\leq n$,表示 $(u, v) \\in E$。保证输入的图构成一棵树。\n\n最后一行包含 $n$ 个互不相同的整数 $a_1, a_2, \\dots, a_n$,保证 $a_i \\in [1, n]$,表示给定的排列。"}},{"title":"Output","value":{"format":"MD","content":"一行输出,若给定排列是一个合法序列则输出 `Yes`,否则输出 `No`"}},{"title":"Sample 1","value":{"format":"MD","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4\n1 2\n1 3\n2 4\n1 2 3 4\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eYes\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Sample 2","value":{"format":"MD","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4\n1 2\n1 3\n2 4\n1 2 4 3\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eNo\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}