MatchCounts
TCCC06 Round 2A · 2006-08-22 · by AdminBrett
TCCC06 Round 2A · 2006-08-22 · by AdminBrett · Recursion
Problem Statement
Problem Statement
The digit d will appear in element i of ability if person i can perform task d. You are required to assign each of the given people to exactly one of the 6 tasks (numbered '0' through '5'). Two people cannot be assigned to the same task. Return the number of assignments possible. Two assignments differ if there is a person who is assigned a different task in each assignment.
Constraints
- ability will contain between 1 and 6 elements, inclusive.
- Each element of ability will contain between 1 and 6 characters, inclusive.
- Each character in ability will be a digit between '0' and '5', inclusive.
- No character will appear more than once in a single element of ability.
Examples
0)
{"045"}
Returns: 3
Person 0 can perform 3 different tasks.
1)
{"01","23"}
Returns: 4
Two choices for person 0 and two choices for person 1.
2)
{"01","01"}
Returns: 2
Both people have two choices, but not all 2*2 possibilities are feasible.
3)
{"0","0"}
Returns: 0
4)
{"012345","012345","012345","012345","012345","012345"}
Returns: 720
Submissions are judged against all 43 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class MatchCounts with a public method int howMany(vector<string> ability) · 43 test cases · 2 s / 256 MB per case