CF1638E.Colorful Operations

提高+/省选-

通过率:0%

时间限制:4.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You have an array a1,a2,…,ana_1,a_2, \dots, a_n. Each element initially has value 00 and color 11. You are also given qq queries to perform:

  • Color ll rr cc: Change the color of elements al,al+1,⋯ ,ara_l,a_{l+1},\cdots,a_r to cc (1≤l≤r≤n1 \le l \le r \le n, 1≤c≤n1 \le c \le n).
  • Add cc xx: Add xx to values of all elements aia_i (1≤i≤n1 \le i \le n) of color cc (1≤c≤n1 \le c \le n, −109≤x≤109-10^9 \le x \le 10^9).
  • Query ii: Print aia_i (1≤i≤n1 \le i \le n).

你有一个数组 a1,a2,…,ana_1,a_2, \dots, a_n。每个元素初始值为 00,颜色为 11。你还需要执行 qq 个查询:

  • Color ll rr cc:将元素 al,al+1,⋯ ,ara_l,a_{l+1},\cdots,a_r 的颜色更改为 cc(其中 1≤l≤r≤n1 \le l \le r \le n,1≤c≤n1 \le c \le n)。
  • Add cc xx:将所有颜色为 cc 的元素 aia_i(1≤i≤n1 \le i \le n)的值增加 xx(其中 1≤c≤n1 \le c \le n,−109≤x≤109-10^9 \le x \le 10^9)。
  • Query ii:输出 aia_i(其中 1≤i≤n1 \le i \le n)。

输入格式

The first line of input contains two integers nn and qq (1≤n,q≤1061 \le n,q \le 10^6) — the length of array aa and the number of queries you have to perform.

Each of the next qq lines contains the query given in the form described in the problem statement.

输入的第一行包含两个整数 nn 和 qq(1≤n,q≤1061 \le n,q \le 10^6)——分别表示数组 aa 的长度以及需要执行的查询次数。

接下来的 qq 行,每行包含一个按题目描述格式给出的查询。

输出格式

Print the answers to the queries of the third type on separate lines.

分别在单独的行中输出第三类查询的答案。

输入输出样例

  • 输入#1

    5 8
    Color 2 4 2
    Add 2 2
    Query 3
    Color 4 5 3
    Color 2 2 3
    Add 3 3
    Query 2
    Query 5

    输出#1

    2
    5
    3
  • 输入#2

    2 7
    Add 1 7
    Query 1
    Add 2 4
    Query 2
    Color 1 1 1
    Add 1 1
    Query 2

    输出#2

    7
    7
    8

说明/提示

The first sample test is explained below. Blue, red and green represent colors 11, 22 and 33 respectively.

第一个样例测试的解释如下。蓝色、红色和绿色分别代表颜色 11、22 和 33。

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

首页