An interesting game
Practice
3 (4 votes)
Algorithms
Dynamic programming
2d dynamic programming
C++
Problem
72% Success 1342 Attempts 50 Points 2s Time Limit 256MB Memory 1024 KB Max Code

Bob and James are about to play with an array \(A[]\) of \(N\) elements with Bob starting the game. In each turn :

  • A player selects a non-zero number of elements from \(A[]\) with the same value and removes them from \(A[]\).

The player whose turn makes array \(A[]\) becomes empty wins the game.

James is very intelligent and he modifies the game a bit. He selects some distinct elements (among those present in \(A\)) and removes all other elements which are not selected from \(A[]\). The game is then played using this modified array.

For example, consider \(A = [1,1,3,12,2,34,2] \). If James chooses values \((1,2,34)\), then the array with which the game is played is \([1,1,2,34,2]\).

Find the number of possible subsets of elements that James can select to modify \(A[]\) such that James is bound to win if both the players play optimally.

Consider an empty subset as a valid answer.

Since the number of possible subsets can be large enough, print the answer modulo \(10^9 + 7\).

Input format

  • The first line contains an integer \(T\) denoting the number of test cases.
  • The second line contains an integer \(N\).
  • The next line contains \(N\) space-separated integers, denoting elements of \(A[]\).

Output format

For each test case, print the number of possible subsets satisfying the criteria modulo \(10^9 + 7\) in a new line.

Constraints

\(1 \le T \le 10 \\ 1 \le N \le 2 \times 10^5 \\ 1 \le A[i] \le 10^{18}\)

 

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:
2D dynamic programmingAlgorithmsDynamic Programming
Points:50
4 votes
Tags:
2D dynamic programmingMathamaticsAlgorithmsData StructuresDynamic Programming
Points:20
8 votes
Tags:
ApprovedProbability distributionEasyMathematicsOpenProbability and StatisticsProbability distribution