Limits 1s, 512 MB

An Automated Disease Prediction system is going to be developed by the students of Leading University, Sylhet.

In this Disease Prediction System, user will input the Symptoms and the System will predict the probability of different diseases.
First the Database of the System has to be developed and then user can ask the query. You have to develop the whole system.

Input

First Line of Input consists of T (Total Number of Test cases)

Then for each test case, there will be one integer n. n indicates total no. of diseases.
Then for each disease, you will take the name of the disease followed by one integer m which indicates total no. of symptoms for that disease. Next m lines will contain the symptom names of that disease.
After taking Symptoms for each disease, there will be a single integer q which indicates total no. of symptoms. Next q lines will contain the symptom names. All the characters of disease name will be in Uppercase.

Constraints:
T <= 5, n <= 100, m <= 10, q <= 10

Output

For each test case, first print the number of the test case followed by the probability of different diseases in descending order. If probabilities of two diseases are same, then print the disease name which is lexicographically smaller. If Probability of a disease is 0, then ignore that case.
(Use two digits after Decimal Point, Check Sample I/O for details)

Sample

InputOutput
1
2
DENGUE FEVER
3
High Fever
Headaches
Vomiting
MALARIA
3
High Fever
Nausea
Diarrhea
2
High Fever
Headaches
Case 1:
DENGUE FEVER -> 0.67
MALARIA -> 0.25

[Probability of a disease = Number of Matched Symptoms of a disease / (Total No. of Symptoms of that disease+ Number of unmatched Symptoms for that disease)]]

From cplusplus.com:
A lexicographical comparison is the kind of comparison generally used to sort words alphabetically in dictionaries; It involves comparing sequentially the elements that have the same position in both ranges against each other until one element is not equivalent to the other. The result of comparing these first non-matching elements is the result of the lexicographical comparison.
If both sequences compare equal until one of them ends, the shorter sequence is lexicographically less than the longer one.

Submit

Login to submit.

Statistics

80% Solution Ratio
lu_juddhaEarliest, Dec '16
steinumFastest, 0.0s
steinumLightest, 5.5 kB
steinumShortest, 1089B
Toph uses cookies. By continuing you agree to our Cookie Policy.