Overview:
At ZapStitch, we always want to analyze everything that we do. So, we have set out to analyze
whom we are communicating with the most and how often in the past 3 months. We want you to
help us analyze this data by generating a report of most frequently communicated contacts.
Task:
- Create a web application where any user can connect or disconnect their gMail account
with the app.
- Get read-only permissions to read emails for a connected gmail account using OAuth.
- Analyze all the email conversations within the last 3 months.
- If the user disconnects his account, the application will not be able to read the
email information any longer.
- This means that by giving OAuth permissions, the application should be able to
read the emails of any account.
- State the End date and pick last 3 calendar months. If it includes, February there
may be only 28 days in the month. If you pick Mar 10 as the end date then Dec
10th should be the starting date to analyze the emails.
- So, emails with the most conversations should be on top.
- Sort the emails based on the most conversations in the descending order.
Email: awesome@gmail.com
Start Date : 10 - Dec - 2014
End Date : 09 - Mar - 2015
Email #convs
abc@gmail.com 23
def@yahoo.com 12
xyz@outlook.com 1
2.The King's Land Sale - 2Max. Marks 40
You might have seen shopkeepers offering sale on their trade items to promote their business - like sale on electronic gadgets or sale on clothing and accessories etc. But have you ever come across something like sale of land ?
Yes, the king of Byteland has grown old and wants to sell away his territory as soon as possible. So he announced a sale on his plot. This drew attention of many land lords and everybody hurried to buy land at the cheapest prices. The king had declared that he would accept bids of only rectangular plots and one needs to mention the diagonally opposite corners(a, b) and (c, d) of the land he wishes to buy. They would write these 4 numbers (a, b, c, d) on a piece of paper, seal it in an airtight envelope and give it to the king.
The king received N such envelopes. As the process was hidden there were many envelopes containing plot descriptions that shared some (or even all) common area. The king now wants to know the union of the areas of all plots that have come under the bidding.
Note that the rectangles made by the plots are always aligned to the rectangular axes, their areas is always positive and c >= a and d >= b.
Constraints
1 ≤ T ≤ 20
1 ≤ N ≤ 20
-10000 ≤ a, b, c, d ≤ 10000
Input
The first line of the input contains the number of test cases T. The description of T test cases follow. Each test case starts with a line containing an integer N, the number of rectangular plots. Then N lines follow, each with 4 space separated integers, a b c d,(a, b) and (c, d) representing the diagonally opposite corners of the plots.
Output
For each test case print one line, the union of the areas of all the plots.
Sample Input(Plaintext Link)
2
2
0 0 2 2
1 1 3 3
2
0 0 3 2
5 6 8 9
Sample Output(Plaintext Link)
7
15
Explanation
1) The individual areas of both plots are 4 each. But they share a common area of 1 between them (between (1, 1) and (2, 2)). Therefore the total area is 4 + 4 - 1 = 7
2)Both the plots of no area in common. So we simply add their individual areas (6 + 9 = 15).
3.The Chocolate GameMax. Marks 80
The person who wrote this problem is going through the bad phase of his life. But, fortunately he won some cash in his last programming event.
Now to make his girlfriend feel special, he wants to buy her some chocolates. As mentioned, he is not having good time so he want to spend as less as possible.
Keeping that in mind, he decided to play a game with her. The rule of game is as follows:
1) There are N chocolates represented by type 1..N
2) He will arrange them in a row in some random order
3) Now she (his girlfriend ofcourse) has to pick an index say i, then she will get all the chocolates at index j such that j>i and type of chocolate at j is strictly less than type of chocolate at index i.
He believes that his girlfriend is not that clever and will surely not choose the most optimal index, but he wants to know that if by any chance she picked the optimal index then how many chocolates will he have to buy.
Input:
First line contain N. then next line contain N space separated integers.
output :
A single integer which is the answer.
Constraints :
1 ≤ N ≤ 105
1<=A[i]<=10^5
Sample Input(Plaintext Link)
10
7 6 10 5 2 8 1 9 3 4