Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Page 1 of 2 DMOPC ' 1 7 Contest 4 P 1 - Ribbon Colouring Fun It is that time of the year when the

Page 1 of 2
DMOPC '17 Contest 4 P1- Ribbon Colouring Fun
It is that time of the year when the carrot has to pay tribute to the magical rabbit overlord again! As a gift, the carrot
decides to prepare an artfully coloured ribbon. She already has a purple ribbon of length and width , but she wants
it to be even more perfect, so she paints some parts of the ribbon blue. More specifically, she does paint strokes, with
the th stroke starting at units from the left end and ending at units from the left end, where and are both
integers. Help her find the total area of purple and blue ribbon!
Constraints
For all subtasks:
Subtask 1[40%]
Subtask 2[60%]
Input Specification
The first line of input will contain two integers, and . The following lines will each contain two integers, and .
Output Specification
Two integers on the same line separated by a space, the first one representing the total purple area, and the second one
the blue area.
Sample Input
43
02
12
34
Sample Output
Time limit: 2.0s Memory limit: 64M
N 1
Q
i xi yi xi yi
0<= xi < yi <= N
1<= N, Q <=1000
1<= N, Q <=100000
N Q Q xi yi
Page 2 of 2
13
Explanation for Sample Output
In the beginning, we have a purple ribbon of length 4. After the first update, the first half of the ribbon is blue. The
second update completely overlaps with the first, so the ribbon does not change. The third update changes the last
quarter to blue, so the total blue area is 3, and the purple area is 43=1.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 1 Lnai 9284

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Carlos Soares ,Joao Gama ,Alipio Jorge

1st Edition

3319235273, 978-3319235271

More Books

Students also viewed these Databases questions