Hectic Game
Practice
4 (4 votes)
Algorithms
Bit manipulation
Easy
Greedy algorithms
Hash maps
Problem
44% Success 4484 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Alice and Bob are playing a hectic game in which there are a total of $$N$$ tasks each consisting of a start time $$S_i$$ and end time $$E_i$$.

Both players take alternate turns, Alice plays first. In each turn, a player chooses the maximum number of tasks that are non-overlapping as both Alice and Bob can perform only one task at a time. In the next turn, the other player will choose the maximum number of tasks that are non-overlapping from the remaining tasks and so on.

Now, both the players will take XOR (Exclusive - OR) of the total tasks count value obtained in each of their turns. Let the value be $$A$$ for Alice and $$B$$ for Bob. Now, If $$A \gt B$$, Alice wins. If $$B \gt A$$, Bob wins. If $$A = B$$, it's a tie. Find out the winner?

Note: The ending time $$E_i$$ for each selected task in each turn should be as less as possible, e.i. if the given tasks are $$[1\;5]$$, $$[3\;8]$$, $$[6\;10]$$, $$[9\;15]$$, Alice can choose maximum 2 tasks in 3 ways as $$[1\;5]$$, $$[6\;10]$$ or $$[1\;5]$$, $$[9\;15]$$ or $$[3\;8]$$, $$[9\;15]$$. Alice will choose $$[1\;5]$$, $$[6\;10]$$ as the ending time for each selected task is as less as possible in this case.

Input Format

The first line of the input will be $$T$$, the total number of test cases.

The first line of each test case will be $$N$$, the total number of tasks.

Then $$N$$ lines follow each consisting of two space-separated integers $$S_i$$ and $$E_i$$ the start time and the end time.

Output Format

For each test case print the respective result Alice, Bob or Tie.

Constraints

\(1 \le T \le 10\)

\(1 \le N \le 10^3\)

\(1 \le S_i \le E_i \le 10^9\)

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:20
34 votes
Tags:
AlgorithmsApprovedEasyGreedy AlgorithmsOpen
Points:20
42 votes
Tags:
AlgorithmsApprovedEasyGreedy AlgorithmsMathOpenSorting
Points:20
5 votes
Tags:
Greedy AlgorithmsAlgorithmsBasics of Greedy Algorithms