#P11219. Red‐Blue Interval Game

    ID: 13287 Type: Default 1000ms 256MiB

Red‐Blue Interval Game

Red‐Blue Interval Game

You are given an array \(a\) of \(n\) non‐negative integers. Initially, each element is colored blue. Two players, youyou and yy, play a game on a subarray of \(a\) in alternating turns; youyou moves first.

The game is defined as follows. Suppose the current subarray (game board) has indices \(L\) to \(R\):

  • If it is youyou's turn, he may choose any contiguous interval of length at most \(c_1\). If the sum of the numbers in that interval is at most \(w_1\) (i.e. \(\sum_{i}\,a_i \le w_1\)), then he colors all numbers in that interval red.
  • If it is yy's turn, he may choose any contiguous interval of length at most \(c_2\). If the sum of the numbers in that interval is greater than \(w_2\) (i.e. \(\sum_{i}\,a_i > w_2\)), then he colors all numbers in that interval blue.

If the current player has no valid interval to operate on, he skips his turn. The win conditions are as follows:

  • youyou wins if at any moment the entire board (i.e. all numbers in the subarray) is red.
  • yy wins if within \(10^{51971}\) turns youyou is unable to achieve an all‐red board.

Both players play optimally. In order to increase the challenge, the following \(q\) operations are performed on the array:

  • If an operation is of the form 1 x y, then increase \(a_x\) by \(y\) (\(0 \le y \le 10^9\)).
  • If an operation is of the form 2 x y, then consider the subarray \(a_x, a_{x+1}, \ldots, a_y\) and imagine a game played on this subarray with the rules described above. Output cont if youyou can force a win; otherwise, output tetris.

Important note on strategy: If the entire subarray can be colored red in one move (i.e. its length is at most \(c_1\) and its sum is at most \(w_1\)), then youyou wins immediately. Otherwise, since after the first move the board is not completely red, yy will try to revert any progress using his move if a valid interval exists. Thus, youyou can only force a win through multiple moves if he can gradually cover the subarray with "safe" moves. A move is considered safe if it cannot be immediately undone by yy. In particular:

  • If a safe move is taken on an interval of length \(L\) and if \(L \le c_2\) then its sum must be at most \(\min(w_1, w_2)\) (so that yy cannot find a subinterval of length \(\le c_2\) with sum greater than \(w_2\)).
  • If \(L > c_2\) then yy cannot choose the entire interval (since his limit is \(c_2\)), and only the condition \(\sum \le w_1\) (for youyou's move) needs to be satisfied.

Thus, one may show that in this problem youyou can force a win on a given subarray if and only if either the subarray can be turned red in one move, or the subarray can be partitioned into intervals of lengths at most \(c_1\) such that for each interval, if its length \(L \le c_2\) then its sum is at most \(\min(w_1, w_2)\), and if \(L > c_2\) then its sum is at most \(w_1\).

You are to process the \(q\) operations in order and answer the queries.

inputFormat

The first line contains six integers \(n, q, c_1, w_1, c_2, w_2\) where \(n\) is the number of elements in the array and \(q\) is the number of operations.

The second line contains \(n\) non‐negative integers \(a_1, a_2, \ldots, a_n\) representing the initial array.

Each of the following \(q\) lines contains an operation in one of the following two formats:

  • 1 x y: Increase \(a_x\) by \(y\) (\(0 \le y \le 10^9\)).
  • 2 x y: Query whether youyou can force a win on the subarray \(a_x, a_{x+1}, \ldots, a_y\).

outputFormat

For each operation of type 2, output a single line containing either cont if youyou can force a win, or tetris otherwise.

sample

5 5 3 10 2 5
1 2 3 4 5
2 1 5
1 3 1
2 1 3
1 5 0
2 2 5
cont

cont cont

</p>