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
Advanced data structures  splay trees, This is a unit of which targeted on...
This is a unit of which targeted on the emerging data structures. Red Black trees, Splay trees, AAtrees & Treaps are introduced. The learner must explore the possibilities of app
Determine the importance of array, Determine the importance of array Ar...
Determine the importance of array Arrays are significant since they allow many values to be stored in a single data structure whereas providing very fast access to each value.
Time complexity of merge sort and heap sort algorithms, What is the time co...
What is the time complexity of Merge sort and Heap sort algorithms? Time complexity of merge sort is O(N log2 N) Time complexity of heap sort is O(nlog2n)
Program, What is a firstinfirstout data structure ? Write algorithms to...
What is a firstinfirstout data structure ? Write algorithms to perform the following operations on it – create, insertion, deletion, for testing overflow and empty conditions.
Merge sorting, ESO207: Programming Assignment 1 Due on 6 Sept, 2015. To be ...
ESO207: Programming Assignment 1 Due on 6 Sept, 2015. To be submitted online. Problem In this assignment you are required to implement kway Merge Sort algorithm. In this version p
Linked list implementation of any circular queue, Link list representation ...
Link list representation of a circular queue is more efficient as it employs space more competently, of course with the added cost of storing the pointers. Program 7 gives the link
Creation of doubly linked list, Program: Creation of Doubly Linked List ...
Program: Creation of Doubly Linked List OUTPUT Input the values of the element 1111 to come out : 1 Input the values of the element 1111 to come out : 2 Inpu
Graph with n vertices will absolutely have a parallel edge, A graph with n ...
A graph with n vertices will absolutely have a parallel edge or self loop if the total number of edges is greater than n1
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
What are the languages which support assertions, What are the languages whi...
What are the languages which support assertions Languages which support assertions often provide different levels of support. For instance, Java has an assert statement which t
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