CF837G.Functions On The Segments
省选/NOI-
通过率:0%
时间限制:5.00s
内存限制:1024MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You have an array f of n functions.The function f__i(x) (1 ≤ i ≤ n) is characterized by parameters: _x_1, _x_2, _y_1, a, b, _y_2 and take values:
- _y_1, if x ≤ _x_1.
- a·x + b, if _x_1 < x ≤ _x_2.
- _y_2, if x > _x_2.
There are m queries. Each query is determined by numbers l, r and x. For a query with number i (1 ≤ i ≤ m), you need to calculate the sum of all f__j(x__i) where l ≤ j ≤ r. The value of x__i is calculated as follows: x__i = (x + last) mod 109, where last is the answer to the query with number i - 1. The value of last equals 0 if i = 1.
你有一个包含 $ n $ 个函数的数组 $ f $。函数 $ f_i(x) $(其中 $ 1 \le i \le n $)由参数 $ x_1, x_2, y_1, a, b, y_2 $ 描述,其取值定义如下:
- 当 $ x \le x_1 $ 时,$ f_i(x) = y_1 $;
- 当 $ x_1 < x \le x_2 $ 时,$ f_i(x) = a \cdot x + b $;
- 当 $ x > x_2 $ 时,$ f_i(x) = y_2 $。
共有 $ m $ 个查询。每个查询由三个数 $ l 、 r $ 和 $ x $ 确定。对于第 $ i $ 个查询($ 1 \le i \le m $),你需要计算所有满足 $ l \le j \le r $ 的 $ f_j(x_i) $ 的和。其中 $ x_i $ 的值按如下方式计算:
xi=(x+last)mod109,
而 $ \text{last} $ 表示前一个查询(即第 $ i-1 $ 个查询)的答案;当 $ i = 1 $ 时,$ \text{last} = 0 $。
输入格式
First line contains one integer number n (1 ≤ n ≤ 75000).
Each of the next n lines contains six integer numbers: _x_1, _x_2, _y_1, a, b, _y_2 (0 ≤ _x_1 < _x_2 ≤ 2·105, 0 ≤ _y_1, _y_2 ≤ 109, 0 ≤ a, b ≤ 104).
Next line contains one integer number m (1 ≤ m ≤ 500000).
Each of the next m lines contains three integer numbers: l, r and x (1 ≤ l ≤ r ≤ n, 0 ≤ x ≤ 109).
第一行包含一个整数 n(1≤n≤75000)。
接下来的 n 行,每行包含六个整数:x1, x2, y1, a, b, y2(满足 0≤x1<x2≤2⋅105,0≤y1,y2≤109,0≤a,b≤104)。
下一行包含一个整数 m(1≤m≤500000)。
接下来的 m 行,每行包含三个整数:l、r 和 x(满足 1≤l≤r≤n,0≤x≤109)。
输入输出样例
输入#1
1 1 2 1 4 5 10 1 1 1 2
输出#1
13
输入#2
3 2 5 1 1 1 4 3 6 8 2 5 7 1 3 5 1 4 10 3 1 3 3 2 3 2 1 2 5
输出#2
19 17 11
输入解题思路,AI测评打分。不知道怎么写?