CF316E3.Summer Homework
提高+/省选-
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
By the age of three Smart Beaver mastered all arithmetic operations and got this summer homework from the amazed teacher:
You are given a sequence of integers _a_1, _a_2, ..., a__n. Your task is to perform on it m consecutive operations of the following type:
- For given numbers x__i and v__i assign value v__i to element a__x__i.
- For given numbers l__i and r__i you've got to calculate sum
, where _f_0 = _f_1 = 1 and at i ≥ 2: f__i = f__i - 1 + f__i - 2. - For a group of three numbers l__i r__i d__i you should increase value a__x by d__i for all x (l__i ≤ x ≤ r__i).
Smart Beaver planned a tour around great Canadian lakes, so he asked you to help him solve the given problem.
三岁的时候,聪明的海狸已经掌握了全部算术运算,今年暑假,他那惊讶不已的老师给他布置了如下作业:
给定一个整数序列 a1,a2,…,an。你需要对该序列依次执行 m 个操作,操作类型如下:
- 给定数字 xi 和 vi,将元素 axi 的值赋为 vi;
- 给定数字 li 和 ri,你需要计算和式
,其中 f0=f1=1,且当 i≥2 时,fi=fi−1+fi−2; - 给定三个数字 li、ri、di,对所有满足 li≤x≤ri 的下标 x,将 ax 的值增加 di。
聪明的海狸计划环游加拿大著名的湖泊,因此请你帮他解决这个问题。
输入格式
The first line contains two integers n and m (1 ≤ n, m ≤ 2·105) — the number of integers in the sequence and the number of operations, correspondingly. The second line contains n integers _a_1, _a_2, ..., a__n (0 ≤ a__i ≤ 105). Then follow m lines, each describes an operation. Each line starts with an integer t__i (1 ≤ t__i ≤ 3) — the operation type:
- if t__i = 1, then next follow two integers x__i v__i (1 ≤ x__i ≤ n, 0 ≤ v__i ≤ 105);
- if t__i = 2, then next follow two integers l__i r__i (1 ≤ l__i ≤ r__i ≤ n);
- if t__i = 3, then next follow three integers l__i r__i d__i (1 ≤ l__i ≤ r__i ≤ n, 0 ≤ d__i ≤ 105).
The input limits for scoring 30 points are (subproblem E1):
- It is guaranteed that n does not exceed 100, m does not exceed 10000 and there will be no queries of the 3-rd type.
The input limits for scoring 70 points are (subproblems E1+E2):
- It is guaranteed that there will be queries of the 1-st and 2-nd type only.
The input limits for scoring 100 points are (subproblems E1+E2+E3):
- No extra limitations.
第一行包含两个整数 n 和 m(1≤n,m≤2⋅105),分别表示序列中整数的个数和操作的个数。第二行包含 n 个整数 a1,a2,…,an(0≤ai≤105)。接下来是 m 行,每行描述一个操作。每行以一个整数 ti(1≤ti≤3)开头,表示操作类型:
- 若 ti=1,则随后是两个整数 xi 和 vi(1≤xi≤n,0≤vi≤105);
- 若 ti=2,则随后是两个整数 li 和 ri(1≤li≤ri≤n);
- 若 ti=3,则随后是三个整数 li、ri 和 di(1≤li≤ri≤n,0≤di≤105)。
得分为 30 分的输入限制(子问题 E1):
- 保证 n 不超过 100,m 不超过 10000,且不包含第 3 类查询。
得分为 70 分的输入限制(子问题 E1+E2):
- 保证只包含第 1 类和第 2 类查询。
得分为 100 分的输入限制(子问题 E1+E2+E3):
- 无额外限制。
输出格式
For each query print the calculated sum modulo 1000000000 (109).
对于每个查询,输出计算得到的和对 1000000000(109)取模的结果。
输入输出样例
输入#1
5 5 1 3 1 2 4 2 1 4 2 1 5 2 2 4 1 3 10 2 1 5
输出#1
12 32 8 50
输入#2
5 4 1 3 1 2 4 3 1 4 1 2 2 4 1 2 10 2 1 5
输出#2
12 45
输入解题思路,AI测评打分。不知道怎么写?