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
Deletion from a redblack tree, Deletion in a RBT uses two main processes, ...
Deletion in a RBT uses two main processes, namely, Procedure 1: This is utilized to delete an element in a given RedBlack Tree. It involves the method of deletion utilized in
Explain the term totalling, Explain the term totalling To add up a ser...
Explain the term totalling To add up a series numbers the subsequent type of statement must be used: Total = total + number This literally means (new) total = (old) t
Explain insertion sort, Q. Explain the insertion sort with a proper algorit...
Q. Explain the insertion sort with a proper algorithm. What is the complication of insertion sort in the worst case?
Bayesian statistics question, Suppose that there is a Beta(2,2) prior distr...
Suppose that there is a Beta(2,2) prior distribution on the probability theta that a coin will yield a "head" when spun in a specified manner. The coin is independently spun 10 tim
Name the four data type groups, There are four data type groups: I...
There are four data type groups: Integer kepts whole numbers and signed numbers Floatingpoint Stores real numbers (fractional values). Perfect for storing bank deposit
Simulation of queues, Simulation of queues: Simulation is the process of f...
Simulation of queues: Simulation is the process of forming an abstract model of a real world situation in order to understand the effect of modifications and the effect of introdu
Tree structure, We would like to implement a 24Tree containing distinct in...
We would like to implement a 24Tree containing distinct integer keys. This 24Tree is defined by the ArrayList Nodes of all the 24Nodes in the tree and the special 24Node Root w
Random searching, write aprogram for random search to implement if a[i]=x;...
write aprogram for random search to implement if a[i]=x;then terminate other wise continue the search by picking new randon inex into a
Graphs with negative edge costs, We have discussed that the above Dijkstra'...
We have discussed that the above Dijkstra's single source shortestpath algorithm works for graphs along with nonnegative edges (like road networks). Given two scenarios can emerg
Frequency count, i:=1 while(i { x:=x+1; i:=i+1; }
i:=1 while(i { x:=x+1; i:=i+1; }
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