Hope you guys had an awesome contest

Before the official editorials are posted (might take a couple of more days), here are brief editorials to the problems-

### PSHOT

The result of the shoot-out can be known as soon as one of the teams has a score which is greater than - the score of the other team + the number of shots remaining for the other team. This is because the other team won’t be able to catch up with the former team even if it manages to score in all its remaining turns and the former team misses in all its remaining turns.

If all turns are over without a clear winner, it will be a draw. We can only know be sure of a draw after all 2N shots have been taken.

## Pseudo-code

```
scoreA = scoreB = 0 //current scores
leftA = leftB = N //shots remaining
for(shot = 1; shot <= 2*N; shot++)
{
if(shot%2 = = 1) //this was A's turn
{
scoreA + = resultOf[shot];
leftA - -;
}
else //this was B's turn
{
scoreB + = resultOf[shot];
leftB - -;
}
// Can we be sure of the result now?
if((scoreA>scoreB+leftB) OR (scoreB>scoreA+leftA) OR (scoreA==scoreB&&shot==2N))
break;
}
print(shot);
```

### XORGM

In the solution permutation C, all (A_1 \oplus C_1) = (A_2 \oplus C_2) = (A_3 \oplus C_3) = \ldots = (A_N \oplus C_N).

Let (A_1 \oplus C_1) = x.

As (A_1 \oplus C_1) = (A_2 \oplus C_2),

\implies(A_2 \oplus C_2) = x.

\implies (A_1 \oplus C_1) \oplus (A_2 \oplus C_2) = (x \oplus x) = 0

\implies (A_1 \oplus C_1) \oplus (A_2 \oplus C_2) \oplus (A_3 \oplus C_3) = (x \oplus x \oplus x) = x

As N is odd,

\implies (A_1 \oplus C_1) \oplus (A_2 \oplus C_2) \oplus (A_3 \oplus C_3) \oplus \dots \oplus (A_N \oplus C_N) = x

The sequence (A_1 \oplus C_1) \oplus (A_2 \oplus C_2) \oplus (A_3 \oplus C_3) \oplus \dots \oplus (A_N \oplus C_N) is nothing but the xor of all values of A and B (C will just be a permutation of B). Thus, after xor-ring all values of A and B, we shall get x.

If we xor x with A_1, we’ll get C_1. Similarly, we can get C_2, C_3, C_4, \ldots C_N by xor-ring the corresponding elements of A with x.

Now, we just need to check if we can obtain this C from B, i.e. , if we can re-arrange the elements of B in some way to get C. There are multiple ways to do this. One way is to compare the frequencies of corresponding elements in these arrays.

If this C is indeed a permutation of B, we have found a solution. We can output C. Else, it is not possible to reorder B to satisfy the given equation and the answer is -1.

### CYCLSUM

Refer to this to learn how to find the **maximum sum subarray**.

The maximum sum prefix of an array is some prefix ending before, say, i, such that the sum of this prefix is greater than the sum of other prefixes of this array. We can define the maximum sum suffix of an array in a similar way.

Let us visualise the rotations in a particular way:

After i rotations, the sequence will be A_i, A_{i+1}, A_{i+2}, \ldots A_N, A_1, A_2, A_3 \ldots A_{i-1}.

Imagine the array has now been cut into two parts,

Part 1: A_i, A_{i+1}, A_{i+2}, \ldots A_N, and

Part 2: A_1, A_2, A_3 \ldots A_{i-1}.

Now, the maximum sum subarray can be either:

- In Part 1, or
- In Part 2, or
- The subarray obtained by joining some suffix of Part 1 with some prefix of Part 2.

This ‘some’ suffix and prefix will actually be the maximum sum suffix of Part 1 and maximum sum prefix of Part 2.

Thus, after a particular rotation, if we know the value of the maximum sum subarray in Part 1, the maximum sum subarray in Part 2, and the values of maximum sum suffix from Part 1 and maximum sum prefix from Part 2, we can compare these and print the maximum among these as the answer for this rotation.

The above values can be obtained for every rotation by extending their previous values (refer to implementations). Thus, we can find the answer for every rotation.

### SLAB

This is a pretty straightforward problem. The tax bracket can be found using if/switch, and then the tax can be calculated, as explained in the problem sample case explanations. Once tax is calculated, it can be subtracted from the income, to get the net income. As N is a multiple of 100, using integer data types, instead of floating-point data types, works too. (Refer to solutions).