CF1638E.Colorful Operations
提高+/省选-
通过率:0%
时间限制:4.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You have an array a1,a2,…,an. Each element initially has value 0 and color 1. You are also given q queries to perform:
- Color l r c: Change the color of elements al,al+1,⋯,ar to c (1≤l≤r≤n, 1≤c≤n).
- Add c x: Add x to values of all elements ai (1≤i≤n) of color c (1≤c≤n, −109≤x≤109).
- Query i: Print ai (1≤i≤n).
你有一个数组 a1,a2,…,an。每个元素初始值为 0,颜色为 1。你还需要执行 q 个查询:
Colorl r c:将元素 al,al+1,⋯,ar 的颜色更改为 c(其中 1≤l≤r≤n,1≤c≤n)。Addc x:将所有颜色为 c 的元素 ai(1≤i≤n)的值增加 x(其中 1≤c≤n,−109≤x≤109)。Queryi:输出 ai(其中 1≤i≤n)。
输入格式
The first line of input contains two integers n and q (1≤n,q≤106) — the length of array a and the number of queries you have to perform.
Each of the next q lines contains the query given in the form described in the problem statement.
输入的第一行包含两个整数 n 和 q(1≤n,q≤106)——分别表示数组 a 的长度以及需要执行的查询次数。
接下来的 q 行,每行包含一个按题目描述格式给出的查询。
输出格式
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 1, 2 and 3 respectively.

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

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