{"trustable":true,"sections":[{"title":"","value":{"format":"MD","content":"\u003ch3\u003eRead problems statements in \u003ca target\u003d\"_blank\" \nhref\u003d\"https://www.codechef.com/download/translated/JUNE17/mandarin/CLONEME.pdf\"\u003eMandarin Chinese\u003c/a\u003e, \u003ca target\u003d\"_blank\" \nhref\u003d\"https://www.codechef.com/download/translated/JUNE17/russian/CLONEME.pdf\"\u003eRussian\u003c/a\u003e and \u003ca target\u003d\"_blank\" \nhref\u003d\"https://www.codechef.com/download/translated/JUNE17/vietnamese/CLONEME.pdf\"\u003eVietnamese\u003c/a\u003e as well.\u003c/h3\u003e\n\n\u003cp\u003eGiven an array \u003cb\u003eA\u003c/b\u003e consisting of \u003cb\u003eN\u003c/b\u003e integers, you have to execute \u003cb\u003eQ\u003c/b\u003e queries on it. These queries ask you to determine whether the two sub-arrays \u003cb\u003ea\u003c/b\u003e to \u003cb\u003eb\u003c/b\u003e and \u003cb\u003ec\u003c/b\u003e to \u003cb\u003ed\u003c/b\u003e, which are of equal length, are \u003ci\u003esimilar\u003c/i\u003e or not. The two sub-arrays \u003cb\u003ea\u003c/b\u003e to \u003cb\u003eb\u003c/b\u003e and \u003cb\u003ec\u003c/b\u003e to \u003cb\u003ed\u003c/b\u003e are said to be \u003ci\u003esimilar\u003c/i\u003e, if, after being sorted individually and then compared element by element, they have at most one mismatch. The output should be YES or NO for each query.\u003c/b\u003e\n\n\u003cp\u003e Note - The two sub-arrays can intersect each other and during the query process they will not affect each other in any way. \u003c/p\u003e\n\n\u003ch3\u003eInput\u003c/h3\u003e\n\u003cp\u003eThe first line of the input contains \u003cb\u003eT\u003c/b\u003e, denoting the number of test cases. The description of \u003cb\u003eT\u003c/b\u003e test cases follows.\u003c/p\u003e\n\u003cp\u003eThe first line of each test case contains two space separated integers: \u003cb\u003eN\u003c/b\u003e and \u003cb\u003eQ\u003c/b\u003e, denoting the number of elements in the array and the number of queries respectively.\u003c/p\u003e\n\u003cp\u003eThe second line contains \u003cb\u003eN\u003c/b\u003e space-separated integers - \u003cb\u003eA\u003csub\u003e1\u003c/sub\u003e\u003c/b\u003e, \u003cb\u003eA\u003csub\u003e2\u003c/sub\u003e\u003c/b\u003e, ..., \u003cb\u003eA\u003csub\u003eN\u003c/sub\u003e\u003c/b\u003e denoting the input array \u003cb\u003eA\u003c/b\u003e. \u003c/p\u003e\n\u003cp\u003eThe next \u003cb\u003eQ\u003c/b\u003e lines contain the queries.\u003c/p\u003e\n\u003cp\u003eThe queries are given as \"\u003cb\u003ea b c d\u003c/b\u003e\" (without the double quotes) where \u003cb\u003ea\u003c/b\u003e and \u003cb\u003eb\u003c/b\u003e are the left and right end point of the first sub-array and \u003cb\u003ec\u003c/b\u003e and \u003cb\u003ed\u003c/b\u003e are the left and right end point of the second sub-array. Both end points are included in a sub-array.\u003c/p\u003e\n\n\u003ch3\u003eOutput\u003c/h3\u003e\n\u003cp\u003eFor each query output \"YES\" or \"NO\" (without the double quotes) depending on whether the two sub-arrays given in that query are \u003ci\u003esimilar\u003c/i\u003e or not.\u003c/p\u003e\n\n\n\u003ch3\u003eConstraints\u003c/h3\u003e\n\u003cp\u003e\u003cb\u003ea\u003c/b\u003e, \u003cb\u003eb\u003c/b\u003e, \u003cb\u003ec\u003c/b\u003e and \u003cb\u003ed\u003c/b\u003e for the queries will always be in the range from \u003cb\u003e1\u003c/b\u003e to \u003cb\u003eN\u003c/b\u003e where \u003cb\u003ea\u003c/b\u003e ≤ \u003cb\u003eb\u003c/b\u003e, \u003cb\u003ec\u003c/b\u003e ≤ \u003cb\u003ed\u003c/b\u003e\u003c/p\u003e and \u003cb\u003eb\u003c/b\u003e - \u003cb\u003ea\u003c/b\u003e \u003d \u003cb\u003ed\u003c/b\u003e - \u003cb\u003ec\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003e\u003cb\u003eTime limit \u003d 2 seconds \u003c/b\u003e\u003c/p\u003e\n\n\u003ch3\u003eSubtasks\u003c/h3\u003e\n\u003cp\u003e\n\u003cb\u003eSubtask #1 (10 points):\u003c/b\u003e\n\u003cul\u003e\n\u003cli\u003e\u003cb\u003e1\u003c/b\u003e ≤ \u003cb\u003eT\u003c/b\u003e ≤ \u003cb\u003e3\u003c/b\u003e\u003c/li\u003e\n\u003cli\u003e\u003cb\u003e1\u003c/b\u003e ≤ \u003cb\u003eN, Q\u003c/b\u003e ≤ \u003cb\u003e10\u003csup\u003e3\u003c/sup\u003e\u003c/b\u003e\u003c/li\u003e\n\u003cli\u003e\u003cb\u003e1\u003c/b\u003e ≤ \u003cb\u003eA[i]\u003c/b\u003e ≤ \u003cb\u003e10\u003csup\u003e3\u003c/sup\u003e\u003c/b\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/p\u003e\n\n\u003cp\u003e\n\u003cb\u003eSubtask #2 (20 points):\u003c/b\u003e\n\u003cul\u003e\n\u003cli\u003e\u003cb\u003e1\u003c/b\u003e ≤ \u003cb\u003eT\u003c/b\u003e ≤ \u003cb\u003e3\u003c/b\u003e\u003c/li\u003e\n\u003cli\u003e\u003cb\u003e1\u003c/b\u003e ≤ \u003cb\u003eN\u003c/b\u003e ≤ \u003cb\u003e10\u003csup\u003e5\u003c/sup\u003e\u003c/b\u003e\u003c/li\u003e\n\u003cli\u003e\u003cb\u003e1\u003c/b\u003e ≤ \u003cb\u003eQ\u003c/b\u003e ≤ \u003cb\u003e10\u003csup\u003e4\u003c/sup\u003e\u003c/b\u003e\u003c/li\u003e\n\u003cli\u003e\u003cb\u003e1\u003c/b\u003e ≤ \u003cb\u003eA[i]\u003c/b\u003e ≤ \u003cb\u003e10\u003csup\u003e5\u003c/sup\u003e\u003c/b\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/p\u003e\n\n\u003cp\u003e\n\u003cb\u003eSubtask #3 (70 points):\u003c/b\u003e\n\u003cul\u003e\n\u003cli\u003e1 ≤ \u003cb\u003eT\u003c/b\u003e ≤ 3\u003c/li\u003e\n\u003cli\u003e1 ≤ \u003cb\u003eN, Q\u003c/b\u003e ≤ 10\u003csup\u003e5\u003c/sup\u003e\u003c/li\u003e\n\u003cli\u003e1 ≤ \u003cb\u003eA[i]\u003c/b\u003e ≤ 10\u003csup\u003e5\u003c/sup\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/p\u003e"}},{"title":"Sample 1","value":{"format":"MD","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\u003e1\n6 3\n1 3 4 2 3 4\n1 3 4 6\n1 2 5 6\n3 5 2 4\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eYES\nNO\nYES\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003cp\u003eIn the first query the first sub-array looks like [1, 3, 4] on sorting and the second sub-array looks like [2, 3, 4] on sorting. These two sub-arrays only differ at first position so they are \u003ci\u003esimilar\u003c/i\u003e.\u003c/p\u003e\n\u003cp\u003eIn the second query the first sub-array on sorting looks like [1, 3] on sorting and the second sub-array looks like [3, 4] on sorting. These two sub-arrays differ at both the positions so they are not \u003ci\u003esimilar\u003c/i\u003e.\u003c/p\u003e\n\u003cp\u003eIn the third query the first sub-array look like [2, 3, 4] on sorting and the second sub-array also looks like [2, 3, 4] on sorting. Since these two sub-arrays don\u0027t differ at any position so they are \u003ci\u003esimilar\u003c/i\u003e.\u003c/p\u003e"}}]}