{"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个整数组成的数组a。 您的任务是确定a是否具有长度至少为3的回文子序列。回顾子序列概念,如[2],[1,2,1,3]和[2,3]是[1,2,1,3]的子序列,但 [1,1,2]和[4]不是它的子序列。\n回顾回文的概念,如数组[1234],[1,2,1],[1,3,2,2,3,1]和[10,100,10]是回文,但数组[1,2]和[1,2,3,1]不是。 \n须回答t组独立测试用例。\n"}},{"title":"Input","value":{"format":"MD","content":"输入的第一行包含一个整数t(1≤t≤100)代表测试用例的数量。 接下来的2t行描述了测试案例。测试用例的第一行包含一个整数n(3≤n≤5000)代表数组a长度。 测试用例的第二行包含n个整数a1,a2,…,an(1≤ai≤n),其中ai是a的第i个元素。 \n保证所有测试用例中n的总和不超过5000(∑n≤5000)。"}},{"title":"Output","value":{"format":"MD","content":"对于每个测试用例,如果a的某个子序列的长度至少为3且为回文,则输出“YES”,否则输出“NO”。"}},{"title":"Example","value":{"format":"MD","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\n3\n1 2 1\n5\n1 2 2 3 2\n3\n1 1 2\n4\n1 2 2 1\n10\n1 1 2 2 3 3 4 4 5 5\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":"MD","content":"\n在该示例的第一个测试案例中,数组a的子序列[1,2,1]是回文。\n\n在示例的第二个测试案例中,数组a具有两个长度为3的子序列,它们是回文:[2,3,2]和[2,2,2]。\n\n在该示例的第三测试情况下,数组a没有长度至少为3的子序列且为回文。\n\n在示例的第四个测试用例中,数组a的一个长度为4的子序列是回文:[1,2,2,1](并且有两个长度为3的子序列是回文:两个都是[1,2 ,1])。\n\n在示例的第五个测试案例中,数组a没有长度至少为3的子序列且是回文。"}}]}