Just a Hook
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 28728 Accepted Submission(s): 14242
Problem Description
In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most ofthe heroes. The hook is made up of several consecutive metallic sticks which are ofthe same length.
Now Pudge wants todo some operations onthehook.
Let us numberthe consecutive metallic sticks ofthe hook from1to N. For each operation, Pudge can change the consecutive metallic sticks, numbered from X to Y, into cupreous sticks, silver sticks or golden sticks.
The total valueofthe hook is calculated asthesumof values of N metallic sticks. More precisely, thevalueforeach kind of stick is calculated as follows:
For each cupreous stick, thevalue is 1.
For each silver stick, thevalue is 2.
For each golden stick, thevalue is 3.
Pudge wants to know the total valueofthe hook after performing the operations.
You may consider the original hook is made up of cupreous sticks.
Input
The input consists of several test cases. The firstlineofthe input is thenumberofthe cases. There are no more than 10 cases.
For eachcase, thefirstlinecontainsaninteger N, 1<=N<=100,000, which is thenumberofthe sticks of Pudge’s meat hook andthesecondlinecontainsaninteger Q, 0<=Q<=100,000, which is thenumberofthe operations.
Next Q lines, eachlinecontainsthree integers X, Y, 1<=X<=Y<=N, Z, 1<=Z<=3, which defines an operation: change the sticks numbered from X to Y intothe metal kind Z, where Z=1 represents the cupreous kind, Z=2 represents the silver kind and Z=3 represents the golden kind.
Output
For eachcase, print anumberinaline representing the total valueofthe hook afterthe operations. Use theformatinthe example.
Sample Input
1102152593
Sample Output
Case 1: The total valueofthe hook is 24.