CF1638E.Colorful Operations

普及/提高-

通过率:0%

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 ( 1lrn1 \le l \le r \le n , 1cn1 \le c \le n ).
  • Add cc xx : Add xx to values of all elements aia_i ( 1in1 \le i \le n ) of color cc ( 1cn1 \le c \le n , 109x109-10^9 \le x \le 10^9 ).
  • Query ii : Print aia_i ( 1in1 \le i \le n ).

输入格式

The first line of input contains two integers nn and qq ( 1n,q1061 \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.

输出格式

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.

首页