{"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":"HTML","content":"\u003cstyle type\u003d\u0027text/css\u0027\u003e .input, .output {border: 1px solid #888888;} .output {margin-bottom:1em;position:relative;top:-1px;} .output pre,.input pre {background-color:#EFEFEF;line-height:1.25em;margin:0;padding:0.25em;} .title {background-color:#FFFFFF;border-bottom: 1px solid #888888;font-family:arial;font-weight:bold;padding:0.25em;} \u003c/style\u003e \u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027]], displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027]]}\n });\n \u003c/script\u003e\n \u003cscript type\u003d\"text/javascript\" async\n src\u003d\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\"\u003e\n \u003c/script\u003e\n\u003cp\u003e给你一棵 n 个节点的树,接下来有 q 次询问\u003c/p\u003e\n\u003cp\u003e每次询问有5个整数x,y,a,b,k \n代表在x和y节点之间加一条边,询问是否存在一条从a节点到b节点(起点是a,终点是b)且长度为k路径\n(一条路径可以多次包含相同的节点和相同的边)\u003c/p\u003e\n\u003cp\u003e每个询问是独立的,即询问结束后删除此询问添加的边,保证添加的边和原有的边不重复,所有的边都是双向的且长度为1,包括添加的边\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003e第一行一个n (3≤n≤105)\u003c/p\u003e\n\u003cp\u003e接下来n-1行,每行2个整数u和v(1≤u,v≤n, u≠v),代表u节点和v节点间有一条边,所有的边都是不同的\u003c/p\u003e\n\u003cp\u003e接下来一行有一个整数q (1≤q≤105)\u003c/p\u003e\n\u003cp\u003e接下来q行,每行5个整数x,y,a,b,k (1≤x,y,a,b≤n, x≠y, 1≤k≤1e9)\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003e每个询问输出一行,如果存在一条a到b且长度为k的路径输出\"YES\",否则输出\"NO\".\u003c/p\u003e"}},{"title":"Example","value":{"format":"HTML","content":"\u003cdiv class\u003d\"sample-test\"\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e5\n1 2\n2 3\n3 4\n4 5\n5\n1 3 1 2 2\n1 4 1 3 2\n1 4 1 3 3\n4 2 3 3 9\n5 2 3 3 9\n\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003eYES\nYES\nNO\nYES\nNO\n\u003c/pre\u003e\n \u003c/div\u003e\n\u003c/div\u003e"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eThe image below describes the tree (circles and solid lines) and the added edges for each query (dotted lines).\u003c/p\u003e\n\u003ccenter\u003e \n \u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/5cd24073aa13c31121848cccdf53342a?v\u003d1605233194\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e \n\u003c/center\u003e\n\u003cp\u003ePossible paths for the queries with \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eYES\u003c/span\u003e\" answers are: \u003c/p\u003e\n\u003cul\u003e \n \u003cli\u003e $$$1$$$-st query: $$$1$$$ – $$$3$$$ – $$$2$$$ \u003c/li\u003e\n \u003cli\u003e $$$2$$$-nd query: $$$1$$$ – $$$2$$$ – $$$3$$$ \u003c/li\u003e\n \u003cli\u003e $$$4$$$-th query: $$$3$$$ – $$$4$$$ – $$$2$$$ – $$$3$$$ – $$$4$$$ – $$$2$$$ – $$$3$$$ – $$$4$$$ – $$$2$$$ – $$$3$$$ \u003c/li\u003e\n\u003c/ul\u003e"}}]}