I need to write a program to find the "patient zero" of a given input, in addition to a few other details. So for this problem, we know the information that...
1) Exactly 1 person started off with the disease.
2) Once a person is infected, they will pass the disease to any person they interact with. However, after K interactions, they will realize they have the disease and santize themselves so that they will not pass the disease in any future interactions.
3) Once a person is infected, they will stay infected (even through the santization). In the problem, we want to find the person who had the disease before the interactions occurred, in addition to the minimal and maximal values of K.
The input composes of an integer N and T. The integer N describes the length of the string following it. The string following it will be comprised of 1s and 0s, where each 1 describes that the person with the respective position is sick, and each 0 describes that the person with the respective position is not sick. For example, in the string (0011), the people labeled 1 and 2 will not be sick, but the people labeled 3 and 4 will be sick. This string describes the status of the people after the interactions. The T interactions will then be labeled with the first number representing the time it took place (a greater time means it took place later), and then the labels of the two people who interacted with each other. One example of an input would be..
4 3 1100 7 1 2 5 2 3 6 2 4
This input shows that persons 1 and 2 are sick after the interactions, but persons 3 and 4 are not. And it shows that at time 7, persons 1 and 2 interacted; at time 5, persons 2 and 3 interacted; at time 6, persons 2 and 4 interacted.
The output should contain the label of the initial patient ("patient zero"), in addition to the minimal and maximal values of K (the amount of interactions people will go before realizing they have the disease and sanitizing themselves). The output for this example input would be...
1 1 Infinity
since the only candidate for the patient zero would be person 1 who would transfer the disease to person 2 due to their interaction at time 7. And K could range from 1 to infinity since we know that there was only one transfer. Note that K could be 0, meaning the initial patient would have no opportunity to transfer the disease to anyone else, and that K could be infinity if we don't have enough information to conclude a definite maximal K. And remember there is always a patient zero.
Aucun commentaire:
Enregistrer un commentaire