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
Avl tree, Example: (Single rotation into AVL tree, while a new node is inse...
Example: (Single rotation into AVL tree, while a new node is inserted into the AVL tree (LL Rotation)) Figure: LL Rotation The rectangles marked A, B & C are trees
Find strongly connected components  dfs, A striking application of DFS is ...
A striking application of DFS is determine a strongly connected component of a graph. Definition: For graph G = (V, E) , where V refer to the set of vertices and E refer to the
What are the objectives of visual realism applications, What are the Object...
What are the Objectives of visual realism applications After studying this unit, you should be able to know specific needs of realism, add realism to pictures by el
Define algorithm, What is an Algorithm? An algorithm is a sequence of u...
What is an Algorithm? An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for getting a needed output for any legitimate input in a finite amoun
What is quick sort, What is quick sort? Answer Quick sort is on...
What is quick sort? Answer Quick sort is one of the fastest sorting algorithm used for sorting a list. A pivot point is chosen. Remaining elements are divided or portio
Define minimum spanning tree, Define Minimum Spanning Tree A minimum sp...
Define Minimum Spanning Tree A minimum spanning tree of a weighted linked graph is its spanning tree of the smallest weight, where the weight of a tree is explained as the sum
Which sorting algorithms not have running time of o (n2), Which sorting al...
Which sorting algorithms does not have a worst case running time of O (n 2 ) ? Merge sort
Conversion of general trees into the binary trees, By taking an appropriate...
By taking an appropriate example explain how a general tree can be represented as a Binary Tree. C onversio
Arrays, Data array A has data series from 1,000,000 to 1 with step size 1, ...
Data array A has data series from 1,000,000 to 1 with step size 1, which is in perfect decreasing order. Data array B has data series from 1 to 1,000,000, which is in random order.
Unidimensional, i cant resolve a problem
i cant resolve a problem
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