A11143 | Functions On The Segments
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $10^{9}$ , where $last$ is the answer to the query with number $i-1$ . The value of $last$ equals $0$ if $i=1$ .
- $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 $10^{9}$ , where $last$ is the answer to the query with number $i-1$ . The value of $last$ equals $0$ if $i=1$ .
输入格式
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·10^{5}$ , $0<=y_{1},y_{2}<=10^{9}$ , $0<=a,b<=10^{4}$ ).
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<=10^{9}$ ).
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·10^{5}$ , $0<=y_{1},y_{2}<=10^{9}$ , $0<=a,b<=10^{4}$ ).
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<=10^{9}$ ).
输出格式
无
输入输出样例
输入 #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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted