Game of sequence
Practice
2.9 (20 votes)
Arrays
Basic programming
Easy
Problem
62% Success 5930 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Two players P and Q are playing a game of sequence on an array A of size n. In each move a player will choose two distinct numbers X and Y , both numbers should be present in the array. Now the player will pick all the positions where the number X is present , and will replace the value there with the number Y.
The game stops if the array has only one distinct value. The player who is unable to make a move in his turn loses.You have to decide who will lose the game. First move is played by the player P.

Input Format
First line contains a number t that denotes total number of test cases.
Second line contains a number n as input denoting total size of the array.
Third line contains n space separated integers denoting the elements in the array A.

Output Format
Output P if the player P loses , Q otherwise.

Input Constraints
\(1 \le t \le 20 \)
\(2 \le n \le 10^5\)
\(0 \le A[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
308 votes
Tags:
Ad-HocAd-hocApprovedBasic ProgrammingEasyHiringOpenReadyRoot
Points:20
30 votes
Tags:
Easy
Points:20
16 votes
Tags:
ApprovedBasic ProgrammingEasy