{"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\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e设 $$$a$$$ 和 $$$b$$$ 分别为长度为 $$$n$$$ 和 $$$m$$$ 的两个数组,且它们没有共同的元素。我们可以按照以下的递归方式定义一个新的长度为 $$$n+m$$$ 的数组 $$$\\mathrm{merge}(a,b)$$$:\u003c/p\u003e\n\u003cul\u003e\n \u003cli\u003e如果其中一个数组为空,则结果为另一个数组。即,$$$\\mathrm{merge}(\\emptyset,b)\u003db$$$ 和 $$$\\mathrm{merge}(a,\\emptyset)\u003da$$$。特别地,$$$\\mathrm{merge}(\\emptyset,\\emptyset)\u003d\\emptyset$$$。\u003c/li\u003e\n \u003cli\u003e如果两个数组都非空,并且 $$$a_1\u0026lt;b_1$$$,那么 $$$\\mathrm{merge}(a,b)\u003d[a_1]+\\mathrm{merge}([a_2,\\ldots,a_n],b)$$$。也就是说,我们删除数组 $$$a$$$ 的第一个元素 $$$a_1$$$,合并剩余的数组,然后将 $$$a_1$$$ 添加到结果的开头。\u003c/li\u003e\n \u003cli\u003e如果两个数组都非空,并且 $$$a_1\u0026gt;b_1$$$,那么 $$$\\mathrm{merge}(a,b)\u003d[b_1]+\\mathrm{merge}(a,[b_2,\\ldots,b_m])$$$。也就是说,我们删除数组 $$$b$$$ 的第一个元素 $$$b_1$$$,合并剩余的数组,然后将 $$$b_1$$$ 添加到结果的开头。\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003e这个算法有一个很好的性质,即如果 $$$a$$$ 和 $$$b$$$ 是排序的,那么 $$$\\mathrm{merge}(a,b)$$$ 也将是排序的。例如,它被用作归并排序中的一个子程序。然而,在这个问题中,我们将考虑同样的过程作用于非排序数组。例如,如果 $$$a\u003d[3,1]$$$ 和 $$$b\u003d[2,4]$$$,那么 $$$\\mathrm{merge}(a,b)\u003d[2,3,1,4]$$$。\u003c/p\u003e\n\u003cp\u003e一个排列是由 $$$n$$$ 个不同的整数组成,这些整数从 $$$1$$$ 到 $$$n$$$ 的任意顺序。例如,$$$[2,3,1,5,4]$$$ 是一个排列,但 $$$[1,2,2]$$$ 不是一个排列($$$2$$$ 在数组中出现两次),$$$[1,3,4]$$$ 也不是一个排列($$$n\u003d3$$$ 但数组中有 $$$4$$$)。\u003c/p\u003e\n\u003cp\u003e有一个长度为 $$$2n$$$ 的排列 $$$p$$$。确定是否存在两个长度为 $$$n$$$ 且没有共同元素的数组 $$$a$$$ 和 $$$b$$$,使得 $$$p\u003d\\mathrm{merge}(a,b)$$$。\u003c/p\u003e"}},{"title":"输入","value":{"format":"HTML","content":"\u003cp\u003e第一行包含一个整数 $$$t$$$($$$1\\le t\\le 1000$$$)— 测试用例的数量。接下来的 $$$2t$$$ 行包含测试用例的描述。\u003c/p\u003e\n\u003cp\u003e每个测试用例的第一行包含一个整数 $$$n$$$($$$1\\le n\\le 2000$$$)。\u003c/p\u003e\n\u003cp\u003e每个测试用例的第二行包含 $$$2n$$$ 个整数 $$$p_1,\\ldots,p_{2n}$$$($$$1\\le p_i\\le 2n$$$)。保证 $$$p$$$ 是一个排列。\u003c/p\u003e\n\u003cp\u003e保证所有测试用例中 $$$n$$$ 的总和不超过 $$$2000$$$。\u003c/p\u003e"}},{"title":"输出","value":{"format":"HTML","content":"\u003cp\u003e对于每个测试用例,如果存在数组 $$$a$$$ 和 $$$b$$$,它们的长度都为 $$$n$$$,且没有共同元素,使得 $$$p\u003d\\mathrm{merge}(a,b)$$$,则输出 \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eYES\u003c/span\u003e\"。否则,输出 \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eNO\u003c/span\u003e\"。\u003c/p\u003e"}},{"title":"示例","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\u003e6\n2\n2 3 1 4\n2\n3 1 2 4\n4\n3 2 6 1 5 7 8 4\n3\n1 2 3 4 5 6\n4\n6 1 3 7 4 5 8 2\n6\n4 3 2 5 1 11 9 12 8 6 10 7\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eYES\nNO\nYES\nYES\nNO\nNO\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"注意","value":{"format":"HTML","content":"\u003cp\u003e在第一个测试用例中,$$$[2,3,1,4]\u003d\\mathrm{merge}([3,1],[2,4])$$$。\u003c/p\u003e\n\u003cp\u003e在第二个测试用例中,我们可以证明 $$$[3,1,2,4]$$$ 不是长度为 $$$2$$$ 的两个数组的合并。\u003c/p\u003e\n\u003cp\u003e在第三个测试用例中,$$$[3,2,6,1,5,7,8,4]\u003d\\mathrm{merge}([3,2,8,4],[6,1,5,7])$$$。\u003c/p\u003e\n\u003cp\u003e在第四个测试用例中,$$$[1,2,3,4,5,6]\u003d\\mathrm{merge}([1,3,6],[2,4,5])$$$,例如。\u003c/p\u003e"}}]}