CF837G.Functions On The Segments

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You have an array ff of nn functions.The function fi(x)f_{i}(x) ( 1<=i<=n1<=i<=n ) is characterized by parameters: x1,x2,y1,a,b,y2x_{1},x_{2},y_{1},a,b,y_{2} and take values:

  • y1y_{1} , if x<=x1x<=x_{1} .
  • ax+ba·x+b , if x_{1}<x<=x_{2} .
  • y2y_{2} , if x>x_{2} .

There are mm queries. Each query is determined by numbers ll , rr and xx . For a query with number ii ( 1<=i<=m1<=i<=m ), you need to calculate the sum of all fj(xi)f_{j}(x_{i}) where l<=j<=rl<=j<=r . The value of xix_{i} is calculated as follows: xi=(x+last)x_{i}=(x+last) mod 10910^{9} , where lastlast is the answer to the query with number i1i-1 . The value of lastlast equals 00 if i=1i=1 .

输入格式

First line contains one integer number nn ( 1<=n<=750001<=n<=75000 ).

Each of the next nn lines contains six integer numbers: x1,x2,y1,a,b,y2x_{1},x_{2},y_{1},a,b,y_{2} ( 0<=x_{1}<x_{2}<=2·10^{5} , 0<=y1,y2<=1090<=y_{1},y_{2}<=10^{9} , 0<=a,b<=1040<=a,b<=10^{4} ).

Next line contains one integer number mm ( 1<=m<=5000001<=m<=500000 ).

Each of the next mm lines contains three integer numbers: ll , rr and xx ( 1<=l<=r<=n1<=l<=r<=n , 0<=x<=1090<=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
    
首页