{"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":"\u003cp\u003e给你一棵有 $n$ 个顶点的无权重树。\u003c/p\u003e\u003cp\u003e你的任务是在这棵树上选择\u003cspan class\u003d\"tex-font-style-bf\"\u003e三个不同\u003c/span\u003e的顶点 $a、b、c$,使得属于 $a$ 和 $b$、$b$ 和 $c$ 或 $a$ 和 $c$ 之间至少一条简单路径的边的数量尽可能多。请参见注释部分以加深理解。\u003c/p\u003e\u003cp\u003eThe simple path is the path that visits each vertex at most once.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains one integer number $$$n$$$ ($$$3 \\le n \\le 2 \\cdot 10^5$$$) — the number of vertices in the tree. \u003c/p\u003e\u003cp\u003eNext $$$n - 1$$$ lines describe the edges of the tree in form $$$a_i, b_i$$$ ($$$1 \\le a_i$$$, $$$b_i \\le n$$$, $$$a_i \\ne b_i$$$). It is guaranteed that given graph is a tree.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eIn the first line print one integer $$$res$$$ — the maximum number of edges which belong to \u003cspan class\u003d\"tex-font-style-bf\"\u003eat least\u003c/span\u003e one of the simple paths between $$$a$$$ and $$$b$$$, $$$b$$$ and $$$c$$$, or $$$a$$$ and $$$c$$$.\u003c/p\u003e\u003cp\u003eIn the second line print three integers $$$a, b, c$$$ such that $$$1 \\le a, b, c \\le n$$$ and $$$a \\ne, b \\ne c, a \\ne c$$$.\u003c/p\u003e\u003cp\u003eIf there are several answers, you can print any.\u003c/p\u003e"}},{"title":"Sample 1","value":{"format":"HTML","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\u003e8\n1 2\n2 3\n3 4\n4 5\n4 6\n3 7\n3 8\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5\n1 8 6\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eThe picture corresponding to the first example (and \u003cspan class\u003d\"tex-font-style-bf\"\u003eanother one correct answer\u003c/span\u003e):\u003c/p\u003e\u003cp\u003e\u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/6d4c715d950959ff03d1ed9e401c24b2?v\u003d1708628873\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e\u003c/p\u003e\u003cp\u003eIf you choose vertices $$$1, 5, 6$$$ then the path between $$$1$$$ and $$$5$$$ consists of edges $$$(1, 2), (2, 3), (3, 4), (4, 5)$$$, the path between $$$1$$$ and $$$6$$$ consists of edges $$$(1, 2), (2, 3), (3, 4), (4, 6)$$$ and the path between $$$5$$$ and $$$6$$$ consists of edges $$$(4, 5), (4, 6)$$$. The union of these paths is $$$(1, 2), (2, 3), (3, 4), (4, 5), (4, 6)$$$ so the answer is $$$5$$$. It can be shown that there is no better answer.\u003c/p\u003e"}}]}