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
Data structures, #quCreate a flowchart to show the process that will allow ...
#quCreate a flowchart to show the process that will allow the implementation of Queue, Enqueue, and Dequeue operations.estion..
Programs, Develop a program that accepts the car registration( hint: LEA 43...
Develop a program that accepts the car registration( hint: LEA 43242010)
Complexity of an algorithm, Q. Explain the complexity of an algorithm? Wha...
Q. Explain the complexity of an algorithm? What are the worst case analysis and best case analysis explain with an example.
Algorithm to insert element to a maxheap sequentially, Q. Write down the ...
Q. Write down the algorithm to insert an element to a maxheap which is represented sequentially. Ans: The algorithm to insert an element "newkey" to
Explain almost complete binary tree, Almost Complete Binary Tree :A binary...
Almost Complete Binary Tree :A binary tree of depth d is an almost whole binary tree if: 1.Any node and at level less than d1 has two children. 2. for any node and in the tree wi
Postfix expression algorithm, Write an algorithm to calculate a postfix exp...
Write an algorithm to calculate a postfix expression. Execute your algorithm using the given postfix expression as your input : a b + c d +*f ↑ . T o evaluate a postfix expr
State about the pre and post conditions, State about the pre and post con...
State about the pre and post conditions Programmers can easily document other pre and post conditions and class invariants, though, and insert code to check most value preco
Tree traversal, Q. What do you understand by the tree traversal? Write down...
Q. What do you understand by the tree traversal? Write down the procedure for traversing a binary tree in preorder and execute it on the following tree. Ans: Th
Difference in grounded header and circular header Link List, Q. State the d...
Q. State the difference between a grounded header link list and a circular header link list? Ans: A header linked list is a linked list which all the time c
Sparse matrices, SPARSE MATRICES Matrices along with good number of zer...
SPARSE MATRICES Matrices along with good number of zero entries are called sparse matrices. Refer the following matrices of Figure (a)
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