CF1545F.AquaMoon and Potatoes

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Subscribe to Technoblade

输入格式

Technoblade has three integer arrays aa, bb, cc of length nn. We have 1ai,bi,cin1 \leq a_i, b_i, c_i \leq n for all ii.

In order to accelerate his potato farming, he organizes his farm in a manner based on these three arrays. He is now going to complete mm operations to count how many potatoes he can get. Each operation will be in one of the two following forms:

  1. Technoblade reorganizes his 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, Technoblade receives a potato for each triplet (i,j,k)(i,j,k), such that 1i<j<kr1\le i<j<k\le r, and bai=aj=cakb_{a_i}=a_j=c_{a_k}. Count the number of potatoes that he receives; that is, the number of such triplets.

Help Technoblade complete these operations.

输出格式

The first line contains two integers nn , mm ( 1n21051\le n\le 2\cdot10^5 , 1m51041\le m\le 5\cdot10^4 ).

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

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

The fourth line contains nn integers c1,c2,,cnc_1, c_2, \dots,c_n ( 1cin1\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 " ( 1k,xn1\le k,x\le n ), representing an operation of the first type.
  • " 2 r2\ r " ( 1rn1\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.

输入输出样例

  • 输入#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
首页