Rick Tries CP

All submissions for this problem are available.
Rick is bored again. This time he decides to try out competitive programming. When he came across the travelling salesman problem, he instantly coded the algorithm and decided to test it out right away. For this, he used his number generator gun to generate $N$ numbers on the Xaxis, and stores them in an array $D$. To obtain some information about the numbers, he asks $Q$ queries on the Xaxis. The $Q$ queries are described as $'L$ $R$ $X$ $Y'$, where $L, R$ denote the endpoints of the range of query (both inclusive), and $X$ and $Y$ are query parameters. For a particular query, for all points on the Xaxis that lie between $L$ and $R$ both inclusive, if their value is $V$ before the query, it changes to $X*V + Y$ after the query. After running all queries, Rick wants to store values at all points belonging to the array $D$. Help him obtain those so that he can write the optimal solution for the traveling salesman problem. ###Input:  First line of the input contains two spaced positive integers $N$ and $Q$ denoting the number of elements in the array D and number of queries respectively.  The next line contains $N$ nonnegative integers denoting the points on the coordinate axis for which you require the information.  Next, $Q$ lines follow, where each line contains a query of type $L$ $R$ $X$ $Y$ where $L$ $R$ denote the range of the query while $X$ and $Y$ are the parameters of the query ###Output: Print the values % $(10^9+7)$ at each of the points belonging to $D$ in a single line where $ith$ no. corresponds to the value of point $D[ i ]$ on the Xaxis. ###Constraints  $1 \leq N \leq 10^5$  $1 \leq Q \leq 10^5$  $1 \leq D[i] \leq 10^{15}$  $0 \leq L \leq R \leq 10^{15}$  $0 \leq X,Y \leq 10^{15}$ ###Sample Input: 3 2 4 5 8 3 7 3 2 0 8 2 5 ###Sample Output: 9 9 5 ###EXPLANATION: when the first query is applied on range 3 to 7, all the point's value changes according to the equation 3x+2, as initially, all no.s are zero, the value of no.s from 3 to 7 becomes 2. When the 2nd query is applied to the range 0 to 8, value at point 4 which is initially 2 changes acc to the equation 2x+5, and hence becomes 9. Similarly, value at point 5 becomes 9 and value at point 8 which was 0 before this query, after this query it becomes 5. Hence the Final answer is 9 9 5.Author:  panik 
Tags  panik 
Date Added:  6012020 
Time Limit:  4 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 