QOJ.ac

QOJ

Limite de temps : 2 s Limite de mémoire : 1024 MB Points totaux : 100

#5098. First-generation Turing Machine

Statistiques

One day, $\text{wind}\_\text{whisper}$ encountered a problem called "Second Generation Turing Machine."

After a long period of struggling, he finally came up with a messy solution. However, although this solution is complicated, it seems it does not rely on random data.

But because $\text{wind}\_\text{whisper}$ has poor coding skills, he found that he could not implement it at all...

So he simplified the operations and created this easy problem.

Since it is a simplified version, let's call it "First Generation Turing Machine."

Description

Given a sequence of $n$ non-negative integers $a_{1...n}$, where each number has a color $c_i \in [1, m]$, you are required to perform $q$ operations of two types:

  • 1 l r: Query the maximum sum of a subsegment within $[l, r]$ that contains no duplicate colors.
  • 2 i w: Change the color $c_i$ to $w$.

Input

The first line contains three positive integers $n, m, q$.

The second line contains $n$ integers, representing $a_{1...n}$.

The third line contains $n$ integers, representing $c_{1...n}$.

The next $q$ lines each describe an operation in the format specified above.

Output

For each type 1 operation, output one integer per line representing the answer.

Examples

Input 1

3 3 3
1 1 2
1 1 2
1 1 3
2 2 2
1 1 3

Output 1

3
2

Examples 2 ~ 4

See the provided files.

Constraints

Subtask ID $n \le $ $q \le $ $m \le $ Special Property Score
$1$ $5\,000$ $5\,000$ $n$ None $10$
$2$ $2 \times 10^5$ $2 \times 10^5$ $10$ $10$
$3$ $n$ No type 2 operations $20$
$4$ $5 \times 10^4$ $5 \times 10^4$ None $20$
$5$ $2 \times 10^5$ $2 \times 10^5$ $40$

For all data, $1\le m\le n\le 2\times 10^5, q\le 2\times 10^5, c_i\in [1, m], 0\le a_i\le 10^9$.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.