Login

Create Account
Customer Service Chat
+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
Graph, Multilist Representation of graph
Multilist Representation of graph
Computer arhitecture, The controversy of RISC versus CISC never ends. Suppo...
The controversy of RISC versus CISC never ends. Suppose that you represent an advocate for the RISC approach; write at least a onepage critic of the CISC approach showing its disa
Program segment for quick sort, Illustrates the program segment for Quick s...
Illustrates the program segment for Quick sort. It uses recursion. Program 1: Quick Sort Quicksort(A,m,n) int A[ ],m,n { int i, j, k; if m { i=m; j=n+1; k
Dqueue, how can i delete from deque while deletion is restricted from one e...
how can i delete from deque while deletion is restricted from one end
Darw a flowchart for inputs number of hours of sunshine, This algorithm inp...
This algorithm inputs number of hours of sunshine recorded every day for a week (7 days). Output is the highest value for hours of sunshine and average (mean) value for numbers of
Algorithms, Write an algorithm to print all even numbers in descending orde...
Write an algorithm to print all even numbers in descending order and draw the flowchart
Explain graph traversal, Graph Traversal In many problems we wish to in...
Graph Traversal In many problems we wish to investigate all the vertices in a graph in some systematic order. In graph we often do not have any single vertex singled out as spe
Tradeoff between space and time complexity, We might sometimes seek a trade...
We might sometimes seek a tradeoff among space & time complexity. For instance, we may have to select a data structure which requires a lot of storage to reduce the computation tim
DAA, what do we use asymptotic notation in study of algorithm?Describe vari...
what do we use asymptotic notation in study of algorithm?Describe various asymptotic notation and give their significance.
Functions and modelling the data flows, Read the scenario (Pickerings Prope...
Read the scenario (Pickerings Properties). (a) List the functions of the system, as perceived by an external user. (b) List the external entities. Note that because we are mo
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
ExpertsMind Services
Online Tutoring
Projects Assistance
Exam Preparation
Coursework Help
Programming Help
IT Services
Why Us ?
~Experienced Tutors
~24x7 hrs Support
~Plagiarism Free
~Quality of Work
~Time on Delivery
~Privacy of Work