You are viewing a single comment's thread. Return to all comments →
Question explained in detailed:
Let's take the first test case. Our array is [1,2,3,4].
First find all its permutations and their score.
Score of a permutation in the maximum of all the values we get by xoring neighbouring elements in the permutation.
In this case:
[1, 2, 3, 4] --> score = max(1^2, 2^3, 3^4) = max(3, 1, 7) = 7 [1, 2, 4, 3] --> score = max(1^2, 2^4, 4^3) = max(3, 6, 7) = 7 [1, 3, 2, 4] --> score = max(1^3, 3^2, 2^4) = max(2, 1, 6) = 6 [1, 3, 4, 2] --> score = max(1^3, 3^4, 4^2) = max(2, 7, 6) = 7 [1, 4, 2, 3] --> score = max(1^4, 4^2, 2^3) = max(5, 6, 1) = 6 [1, 4, 3, 2] --> score = max(1^4, 4^3, 3^2) = max(5, 7, 1) = 7 [2, 1, 3, 4] --> score = max(2^1, 1^3, 3^4) = max(3, 2, 7) = 7 [2, 1, 4, 3] --> score = max(2^1, 1^4, 4^3) = max(3, 5, 7) = 7 [2, 3, 1, 4] --> score = max(2^3, 3^1, 1^4) = max(1, 2, 5) = 5 [2, 3, 4, 1] --> score = max(2^3, 3^4, 4^1) = max(1, 7, 5) = 7 [2, 4, 1, 3] --> score = max(2^4, 4^1, 1^3) = max(6, 5, 2) = 6 [2, 4, 3, 1] --> score = max(2^4, 4^3, 3^1) = max(6, 7, 2) = 7 [3, 1, 2, 4] --> score = max(3^1, 1^2, 2^4) = max(2, 3, 6) = 6 [3, 1, 4, 2] --> score = max(3^1, 1^4, 4^2) = max(2, 5, 6) = 6 [3, 2, 1, 4] --> score = max(3^2, 2^1, 1^4) = max(1, 3, 5) = 5 [3, 2, 4, 1] --> score = max(3^2, 2^4, 4^1) = max(1, 6, 5) = 6 [3, 4, 1, 2] --> score = max(3^4, 4^1, 1^2) = max(7, 5, 3) = 7 [3, 4, 2, 1] --> score = max(3^4, 4^2, 2^1) = max(7, 6, 3) = 7 [4, 1, 2, 3] --> score = max(4^1, 1^2, 2^3) = max(5, 3, 1) = 5 [4, 1, 3, 2] --> score = max(4^1, 1^3, 3^2) = max(5, 2, 1) = 5 [4, 2, 1, 3] --> score = max(4^2, 2^1, 1^3) = max(6, 3, 2) = 6 [4, 2, 3, 1] --> score = max(4^2, 2^3, 3^1) = max(6, 1, 2) = 6 [4, 3, 1, 2] --> score = max(4^3, 3^1, 1^2) = max(7, 2, 3) = 7 [4, 3, 2, 1] --> score = max(4^3, 3^2, 2^1) = max(7, 1, 3) = 7
Our answer is the minimum of these scores. In this case, it is 5.
Seems like cookies are disabled on this browser, please enable them to open this website
Yet Another Minimax Problem
You are viewing a single comment's thread. Return to all comments →
Question explained in detailed:
Let's take the first test case. Our array is [1,2,3,4].
First find all its permutations and their score.
Score of a permutation in the maximum of all the values we get by xoring neighbouring elements in the permutation.
In this case:
Our answer is the minimum of these scores. In this case, it is 5.