CF1545F.AquaMoon and Potatoes

NOI/NOI+/CTSC

通过率:0%

时间限制:7.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

AquaMoon has three integer arrays aa, bb, cc of length nn, where 1≤ai,bi,ci≤n1 \leq a_i, b_i, c_i \leq n for all ii.

In order to accelerate her potato farming, she organizes her farm in a manner based on these three arrays. She is now going to complete mm operations to count how many potatoes she can get. Each operation will have one of the two types:

  1. AquaMoon reorganizes their farm and makes the kk-th element of the array aa equal to xx. In other words, perform the assignment ak:=xa_k := x.
  2. Given a positive integer rr, AquaMoon receives a potato for each triplet (i,j,k)(i,j,k), such that 1≤i<j<k≤r1\le i \lt j \lt k\le r, and bai=aj=cakb_{a_i}=a_j=c_{a_k}. Count the number of such triplets.

As AquaMoon is busy finding the library, help her complete all of their operations.

AquaMoon 有三个长度为 nn 的整数数组 aa、bb、cc,其中对所有 ii 均满足 1≤ai,bi,ci≤n1 \leq a_i, b_i, c_i \leq n。

为了加速她的土豆种植,她依据这三个数组来规划农场布局。现在她将执行 mm 个操作,以统计她能收获多少土豆。每个操作属于以下两种类型之一:

  1. AquaMoon 重新规划农场,将数组 aa 的第 kk 个元素修改为 xx。即执行赋值操作 ak:=xa_k := x。
  2. 给定一个正整数 rr,AquaMoon 对每个满足 1≤i<j<k≤r1\le i \lt j \lt k\le r 且 bai=aj=cakb_{a_i}=a_j=c_{a_k} 的三元组 (i,j,k)(i,j,k) 收获一个土豆。统计满足条件的三元组个数。

由于 AquaMoon 正忙于寻找图书馆,请你帮她完成所有这些操作。

输入格式

The first line contains two integers nn, mm (1≤n≤2⋅1051\le n\le 2\cdot10^5, 1≤m≤5⋅1041\le m\le 5\cdot10^4).

The second line contains nn integers a1,a2,…,ana_1, a_2, \dots,a_n (1≤ai≤n1\le a_i\le n).

The third line contains nn integers b1,b2,…,bnb_1, b_2, \dots,b_n (1≤bi≤n1\le b_i\le n).

The fourth line contains nn integers c1,c2,…,cnc_1, c_2, \dots,c_n (1≤ci≤n1\le c_i\le n).

The next mm lines describe operations, the ii-th line describes the ii-th operation in one of these two formats:

  • "1 k x1\ k\ x" (1≤k,x≤n1\le k,x\le n), representing an operation of the first type.
  • "2 r2\ r" (1≤r≤n1\le r\le n), representing an operation of the second type.

It is guaranteed that there is at least one operation of the second type.

第一行包含两个整数 nn、mm(1≤n≤2⋅1051\le n\le 2\cdot10^5,1≤m≤5⋅1041\le m\le 5\cdot10^4)。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \dots,a_n(1≤ai≤n1\le a_i\le n)。

第三行包含 nn 个整数 b1,b2,…,bnb_1, b_2, \dots,b_n(1≤bi≤n1\le b_i\le n)。

第四行包含 nn 个整数 c1,c2,…,cnc_1, c_2, \dots,c_n(1≤ci≤n1\le c_i\le n)。

接下来的 mm 行描述操作,其中第 ii 行描述第 ii 个操作,格式为以下两种之一:

  • “1 k x1\ k\ x”(1≤k,x≤n1\le k,x\le n),表示第一类操作。
  • “2 r2\ r”(1≤r≤n1\le r\le n),表示第二类操作。

保证至少存在一个第二类操作。

输出格式

For each operation of the second type print the answer.

对于每种第二类操作,请输出答案。

输入输出样例

  • 输入#1

    5 4
    1 2 3 4 5
    2 3 4 5 1
    5 1 2 3 4
    2 5
    1 2 3
    2 4
    2 5

    输出#1

    3
    0
    2

说明/提示

For the first operation, the triplets are:

  • i=1i=1, j=2j=2, k=3k=3
  • i=2i=2, j=3j=3, k=4k=4
  • i=3i=3, j=4j=4, k=5k=5

There is no satisfying triplet for the third operation.

For the fourth operation, the triplets are:

  • i=2i=2, j=4j=4, k=5k=5
  • i=3i=3, j=4j=4, k=5k=5

对于第一次操作,满足条件的三元组为:

  • i=1i=1, j=2j=2, k=3k=3
  • i=2i=2, j=3j=3, k=4k=4
  • i=3i=3, j=4j=4, k=5k=5

第三次操作不存在满足条件的三元组。

对于第四次操作,满足条件的三元组为:

  • i=2i=2, j=4j=4, k=5k=5
  • i=3i=3, j=4j=4, k=5k=5

输入解题思路,AI测评打分。不知道怎么写?

首页