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
Whether a binary tree is a binary search tree or not, Write an algorithm to...
Write an algorithm to test whether a Binary Tree is a Binary Search Tree. The algorithm to test whether a Binary tree is as Binary Search tree is as follows: bstree(*tree) {
Which sorting methods sorting a list which is almost sorted, Which sorting ...
Which sorting methods would be most suitable for sorting a list which is almost sorted Â Bubble Sorting method.
What are the advantages of using assertions, Using Assertions When writ...
Using Assertions When writing code, programmer must state pre and subtle post conditions for public operations, state class invariants and insert unreachable code assertions a
Explain time complexity, Time Complexity, Big O notation The amount of ...
Time Complexity, Big O notation The amount of time needed by an algorithm to run to its completion is referred as time complexity. The asymptotic running time of an algorithm i
Prime''z algorithem, Ask question #explain it beriflyMinimum 100 words acce...
Ask question #explain it beriflyMinimum 100 words accepted#
Binary search, Explain binary search with an example
Explain binary search with an example
Create a function to show data structure, Given a number that is represente...
Given a number that is represented in your data structure, you will need a function that prints it out in base 215 in such a way that its contents can be checked for correctness. Y
Which is the most suitable data type, Problem 1. You are asked to store...
Problem 1. You are asked to store Names of all 100 students of class A in your Learning Centre. Which data type will you use? What is its syntax? Explaining the data typ
Explain state space tree, Explain State Space Tree If it is convenient ...
Explain State Space Tree If it is convenient to execute backtracking by constructing a tree of choices being made, the tree is known as a state space tree. Its root indicates a
Infix to postfix conversion, A*(B+D)/EF*(G+H/K)
A*(B+D)/EF*(G+H/K)
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