Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

On 12 June 1942, Anne received a diary as a gift. She started writing on it. Later, her diary had become a part of history as it is considered an important document of World War II.

In order to make Anne’s work available online, you will have to write a program that will answer some queries. Initially, you will be given the list of days when Anne wrote on her diary. Based on this given list, you will have to answer some queries. In each query, you will be given two dates and you will have to answer how many days Anne had written in her diary between these two given dates.

The first line of the input will contain an integer $N$ ($1 \leq N \leq 200$), the total number of days Anne had written in her diary. In the next $N$ lines, there will be a day in the format:

Month Day, Year

The values of the Month will be from January, February, March, April, May, June, July, August, September, October, November and December.

The next line will contain an integer $Q$ ($1 \leq Q \leq 40000$), the total number of queries.

Each query will have two valid dates each on a line by itself. The first date will be earlier or equal to the second date.

The value of all the dates can be any valid date from June 12, 1942 to December 31, 1944.

For each query, output one line, the number of days Anne has written in her diary within the given two dates.

Input | Output |
---|---|

2 June 12, 1942 June 21, 1942 1 June 15, 1942 June 22, 1942 | 1 |

73% Solution Ratio

BigBagEarliest,

TurinhstuFastest, 0.0s

BigBagLightest, 131 kB

anonyo.akandShortest, 291B

Login to submit

First, the dates when Anne had written in her diary can be sorted, although it is not necessary with...

Toph uses cookies. By continuing you agree to our Cookie Policy.