{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv id\u003d\"problem-body\"\u003e\n\t\u003cp\u003eYou are given an array of n integers (0 \u0026lt;\u003d n \u0026lt;\u003d 1000). Find a contiguous subsequence of these numbers [a\u003csub\u003ei\u003c/sub\u003e, a\u003csub\u003ej\u003c/sub\u003e] (1 \u0026lt;\u003d i, j \u0026lt;\u003d n), such that the Exclusive-OR of these numbers is maximum. (That is, a\u003csub\u003ei\u003c/sub\u003e XOR a\u003csub\u003ei+1\u003c/sub\u003e XOR ... a\u003csub\u003ej\u003c/sub\u003e should be maximum).\u003c/p\u003e\r\n\r\n\u003ch3\u003eInput\u003c/h3\u003e\r\n\u003cp\u003eThe test case contains exactly 2 lines of input.\u003c/p\u003e\r\n\u003cp\u003eThe first line contains a single integer n (0 \u0026lt;\u003d n \u0026lt;\u003d 1000), the total number of integers in the sequence given to you.\u003c/p\u003e\r\n\u003cp\u003eThe next line contains n space separated integers such that the ith integer denotes a\u003csub\u003ei\u003c/sub\u003e. (0 \u0026lt;\u003d a\u003csub\u003ei\u003c/sub\u003e \u0026lt;\u003d 10\u003csup\u003e9\u003c/sup\u003e). Note that these integers need not necessarily be distinct.\u003c/p\u003e\r\n\r\n\u003ch3\u003eOutput\u003c/h3\u003e\r\n\u003cp\u003eOutput two lines. In the first line, print out the value of the maximum XOR.\u003c/p\u003e\r\n\u003cp\u003eIn the second line, print out i and j with a space separating them, such that [a\u003csub\u003ei\u003c/sub\u003e, a\u003csub\u003ej\u003c/sub\u003e] (both endpoints inclusive) denotes the contiguous subsequence with the maximum XOR value.\u003c/p\u003e\r\n\u003cp\u003eIn case there is more than one subsequence with the maximum XOR value, print out the pair (i, j) such that (i, j) is lexicographically smallest. (Formally, we say that a pair (a, b) is lexicographically smaller than another pair (c, d) if and only if (i) a \u0026lt; c or (ii) a\u003dc and b \u0026lt; d.)\u003c/p\u003e\r\n\u003cp\u003e\u003cstrong\u003eNOTE\u003c/strong\u003e : The subsequence must be non-empty, but may be allowed to contain just one integer. (i.e, in this case, i \u003d j)\u003c/p\u003e\r\n\r\n\u003ch3\u003eExample\u003c/h3\u003e\r\n\u003cdiv\u003e\u003ctable class\u003d\"vjudge_sample\"\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\r\n4\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4\r\n1 1\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\r\n\r\n\u003cdiv\u003e\u003ctable class\u003d\"vjudge_sample\"\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\u003e3\r\n1 2 3\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\r\n1 2\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\r\n\r\n\u003ch3\u003eExplanation\u003c/h3\u003e\r\n\u003col\u003e\r\n\u003cli\u003eIn the first test case, since there is only one number, the maximum XOR would be simply the value of that number (in this case, 4), and i \u003d j \u003d 1.\u003c/li\u003e\r\n\u003cli\u003eIn the second test case, the maximum XOR value is 3, but there are 2 contiguous subsequences that define the same XOR value - (i) [1, 2] since 1 XOR 2 \u003d 3 (ii) [3, 3] since this subsequence contains just the single integer 3. But since [1, 2] is lexicographically smaller than [3, 3], [1, 2] is the desired output.\u003c/li\u003e\r\n\u003c/ol\u003e\r\n\n\u003c/div\u003e"}}]}