{"trustable":true,"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$$$个动物图案组成。图案按照旋转木马的运动顺序从$$$1$$$编号到$$$n$$$编号。因此,在第$$$n$$$个图案之后是编号为$$$1$$$的图案。每个图案都有自己的类型 — 对应于该图案的动物类型(马、老虎等)。第$$$i$$$个图案的动物类型等于$$$t_i$$$。\u003c/p\u003e\u003ccenter\u003e \u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/f63e69fbba21c1a026f5adfe36db8ede?v\u003d1701946829\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e \u003cspan class\u003d\"tex-font-size-small\"\u003e以$$$n\u003d9$$$和$$$t\u003d[5, 5, 1, 15, 1, 5, 5, 1, 1]$$$为例的旋转木马示例。\u003c/span\u003e \u003c/center\u003e\u003cp\u003e你想要用一种颜色给每个图案上色。你认为如果旋转木马连续出现两个不同类型的图案(动物类型不同)并且上了相同的颜色,那就太无聊了。\u003c/p\u003e\u003cp\u003e你的任务是以最小可能的不同颜色数上色,且不会出现不同类型的图案相邻且上了相同颜色的情况。如果你使用了恰好$$$k$$$种不同颜色,那么图案的颜色应该用从$$$1$$$到$$$k$$$的整数表示。\u003c/p\u003e"}},{"title":"输入","value":{"format":"HTML","content":"\u003cp\u003e输入包含一个或多个测试用例。\u003c/p\u003e\u003cp\u003e第一行包含一个整数$$$q$$$($$$1 \\le q \\le 10^4$$$) — 测试用例的数量。接下来是$$$q$$$个测试用例。一个测试用例占两行。\u003c/p\u003e\u003cp\u003e测试用例的第一行包含一个整数$$$n$$$($$$3 \\le n \\le 2 \\cdot 10^5$$$) — 旋转木马上图案的数量。图案按照旋转木马的运动顺序从$$$1$$$编号到$$$n$$$编号。假设在第$$$n$$$个图案之后是编号为$$$1$$$的图案。\u003c/p\u003e\u003cp\u003e测试用例的第二行包含$$$n$$$个整数$$$t_1, t_2, \\dots, t_n$$$($$$1 \\le t_i \\le 2 \\cdot 10^5$$$),其中$$$t_i$$$是第$$$i$$$个图案的动物类型。\u003c/p\u003e\u003cp\u003e所有测试用例中$$$n$$$的总和不超过$$$2\\cdot10^5$$$。\u003c/p\u003e"}},{"title":"输出","value":{"format":"HTML","content":"\u003cp\u003e输出$$$q$$$个答案,对于每个测试用例打印两行。\u003c/p\u003e\u003cp\u003e在第一行打印一个整数$$$k$$$ — 图案的最小可能不同颜色数。\u003c/p\u003e\u003cp\u003e在第二行打印$$$n$$$个整数$$$c_1, c_2, \\dots, c_n$$$($$$1 \\le c_i \\le k$$$),其中$$$c_i$$$是第$$$i$$$个图案的颜色。如果有多个答案,你可以打印任意一个。\u003c/p\u003e"}},{"title":"示例 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\u003e4\n5\n1 2 1 2 2\n6\n1 2 2 1 2 2\n5\n1 2 1 2 3\n3\n10 10 10\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\n1 2 1 2 2\n2\n2 1 2 1 2 1\n3\n2 3 2 3 1\n1\n1 1 1 \n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}}]}