Login

Create Account
+14156709189
info@expertsmind.com
Submit Homework/Assignment
Get quote & make Payment
Get Solution
Dynamic programming., Data Structure & Algorithms
Count Scorecards(30 points)
In a tournament, N players play against each other exactly once. Each game results in either of the player winning. There are no ties. You have given a scorecard containing the scores of each player at the end of the tournament. The score of a player is the total number of games the player won in the tournament. However, the scores of some players might have been erased from the scorecard. How many possible scorecards are consistent with the input scorecard?
Input:
The first line contains the number of cases T. T cases follow. Each case contains the number N on the first line followed by N numbers on the second line. The ith number denotes s_i, the score of the ith player. If the score of the ith player has been erased, it is represented by 1.
Output:
Output T lines, containing the answer for each case. Output each result modulo 1000000007.
Constraints:
1 <= T <= 20
1 <= N <= 40
1 <= s_i < N
Sample Input:
5
3
1 1 2
3
1 1 1
4
0 1 2 3
2
1 1
4
1 1 1 2
Sample Output:
2
7
1
0
12
Explanation:
For the first case, there are 2 scorecards possible: {0,1,2} or {1,0,2}.
For the second case, the valid scorecards are {1,1,1}, {0,1,2}, {0,2,1}, {1,0,2}, {1,2,0}, {2,0,1}, {2,1,0}.
For the third case, the only valid scorecard is {0,1,2,3}.
For the fourth case, there is no valid scorecard. It is not possible for both players to have score 1.
Posted Date: 6/30/2012 6:58:09 PM  Location : United States
Ask an Expert
Related Discussions:
Dynamic programming., Assignment Help, Ask Question on Dynamic programming., Get Answer, Expert's Help, Dynamic programming. Discussions
Write discussion on Dynamic programming.
Your posts are moderated
Write your message here..
Related Questions
Explain optimal binary search trees, Explain Optimal Binary Search Trees ...
Explain Optimal Binary Search Trees One of the principal application of Binary Search Tree is to execute the operation of searching. If probabilities of searching for elements
Algorithm to add an element at the end of linked list, Write an algorithm t...
Write an algorithm to add an element at the end of circular linked list. Algorithm to Add the Element at the End of Circular Linked List. IINSENDCLL( INFO, LINK, START, A
Algorithm for linear search, Here, m represents the unordered array of ele...
Here, m represents the unordered array of elements n represents number of elements in the array and el represents the value to be searched in the list Sep 1: [Initialize]
Implementation of tree, The most common way to insert nodes to a general tr...
The most common way to insert nodes to a general tree is to first discover the desired parent of the node you desire to insert, and then insert the node to the parent's child list.
Multiple queue, How to create multiple queue on single array?
How to create multiple queue on single array?
Tree traversals, There are three kinds of tree traversals, namely, Postorde...
There are three kinds of tree traversals, namely, Postorder , Preorder and Inorder. Preorder traversal: Each of nodes is visited before its children are visited; first the roo
Binary search tree bst, Describe Binary Search Tree (BST)? Make a BST for t...
Describe Binary Search Tree (BST)? Make a BST for the given sequence of numbers. 45, 36, 76, 23, 89, 115, 98, 39, 41, 56, 69, 48 Traverse the obtained tree in Preorder, Inord
Estimate cost of an optimal diapath, Normally a potential y satisfies y r ...
Normally a potential y satisfies y r = 0 and 0 ³ y w  c vw y v . Given an integer K³0, define a Kpotential to be an array y that satisfies yr = 0 and K ³ y w  c vw y v
Algorithm for dfs, Step 1: Choose a vertex in the graph and make it the sou...
Step 1: Choose a vertex in the graph and make it the source vertex & mark it visited. Step 2: Determine a vertex which is adjacent to the source vertex and begun a new search if
Sparse matrix, How sparse matrix stored in the memory of a computer?
How sparse matrix stored in the memory of a computer?
Assignment Help
Accounting Assignment Help
Economics Assignment Help
Finance Assignment Help
Statistics Assignment Help
Physics Assignment Help
Chemistry Assignment Help
Math Assignment Help
Biology Assignment Help
English Assignment Help
Management Assignment Help
Engineering Assignment Help
Programming Assignment Help
Computer Science Assignment Help
IT Courses and Help
ExpertsMind Services
Online Tutoring
Projects Assistance
Exam Preparation
Coursework Help
Programming Courses
Engineering Courses
Why Us ?
~Experienced Tutors
~24x7 hrs Support
~Plagiarism Free
~Quality of Work
~Time on Delivery
~Privacy of Work