Hash and Evil Cat
Practice
5 (1 votes)
Hard
Problem
44% Success 38 Attempts 50 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Hash and Evil Cat are playing a game of painting rectangles. There are N rectangles. Rectangles are drawn on the floor such that no two rectangles intersect with each other but they can lie entirely within each other. The co-ordinates of the bottom-left and top-right corners of all the rectangles are known. Now Hash and the Evil Cat take turns to paint rectangles. During one's turn one has to choose one rectangle and paint it. If a rectangle is painted, all the rectangles inside it gets painted. One cannot paint a rectangle that is already painted (if only some of the inner rectangles are painted, the rectangle is still considered as not painted). The loser is the one who cannot make a turn. Considering both play optimally and Hash gets the first turn, determine who wins the game. If Hash wins then also determine which rectangle he should paint in the first turn.

Input Format:

First line contains an integer T denoting the number of test cases.
For each test case the first line contains the integer N.
The next N lines contain four space separated integers x1, y1, x2 and y2 where (x1,y1) and (x2,y2) are the co-ordinates of the bottom-left and top-right corners of each rectangle respectively.

Constraints:

1<=T<=10
1<=N<=50000
x1,y1,x2,y2<=106
The total number of rectangles won't exceed 100000.

Output Format:

For each test case, if Evil Cat wins output "Evil Cat".
If Hash wins output "Hash x" - where x is the index (as per the input order) of the rectangle that Hash paints in the first turn. If there are multiple such rectangles, x is the smallest such index.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:50
2 votes
Tags:
AlgorithmsHard