#P10582. Matrix Game Strategy
Matrix Game Strategy
Matrix Game Strategy
In a challenging strategic game, two players, Xiao Lan and Xiao Qiao, take turns operating on an initially zero n×n matrix. The game proceeds as follows:
- Xiao Lan (the first player) starts and in each turn he chooses any 2 elements of the matrix and sets them to 1.
- Xiao Qiao (the second player) then takes his turn. In his ith turn, he must choose an i×i contiguous submatrix and reset all its elements to 0. For example, in his first turn he chooses a 1×1 submatrix, in his second turn a 2×2 submatrix, and so on.
- This alternating process continues until both players have taken exactly n turns.
Define X as the maximum number of elements equal to 1 that appear in the matrix at any moment during the game. Xiao Lan tries to maximize this value, while Xiao Qiao tries to minimize it. Assuming both players play optimally (i.e. both have perfect logical reasoning), determine the value of X in terms of n.
More formally, you are given an integer \(n\) and you need to compute the maximum number of ones the matrix ever attains when both players use optimal strategies. Through analysis one can show that the answer is:
[ X = n + 1 ]
Note: The formula above is derived by noticing that Xiao Lan can always arrange his placements so that in the first n-1 rounds, Xiao Qiao can remove only one 1 per turn, and in the final round the entire board (the only possible n×n submatrix) is reset. However, the maximum is achieved immediately after Xiao Lan's move in the final round before deletion.
inputFormat
The input consists of a single integer n
(\(1 \leq n \leq 10^5\)), representing both the size of the matrix and the number of moves each player will take.
outputFormat
Output the integer X, which is the maximum number of 1's in the matrix at any point during the game under optimal play.
sample
1
2