P9695 [GDCPC 2023] Traveling in Cells
Description
There are $n$ cells arranged in a row. The $i$-th cell has a color $c_i$ and contains a ball with value $v_i$.
You're going to travel several times in the cells. For each travel, you'll be given an integer $x$ and a set of colors $\mathbb{A} = \{a_1, a_2, \cdots, a_k\}$ where $c_x \in \mathbb{A}$. The travel starts from cell $x$. During the travel, if you're located in cell $i$ you can next move to cell $(i - 1)$ or $(i + 1)$. Note that you can't move out of these $n$ cells. Also at any time, the color of cell you're located in must belong to set $\mathbb{A}$.
When you're in cell $i$, you can choose to remove the ball in the cell and gain its value $v_i$. As there is only one ball in each cell, you can only remove the ball from each cell once.
Your task is to process $q$ operations in order. Each operation is one of the following three types:
- $1\; p \; x$: Change $c_p$ to $x$.
- $2\; p \; x$: Change $v_p$ to $x$.
- $3\; x\; k\; a_1\; a_2 \; \ldots\; a_k$: Given the starting cell $x$ and the color set $\mathbb{A} = \{a_1, a_2, \cdots, a_k\}$ of a travel, imagine that you're going on this travel, calculate the maximum total value you can gain. Note that this travel is only an imagination, thus the balls won't be truely removed. That is, all queries are independent.
Input Format
N/A
Output Format
N/A