Huawei OD Computer Test Real Questions - Accurate Nucleic Acid Testing - 2023 OD Unified Examination (Paper C)

Topic description:

In order to meet the needs of accurate prevention and control of the new coronavirus epidemic and to avoid the waste caused by nucleic acid testing of all employees, it is necessary to accurately identify the groups of people who may be infected.
Now, based on infectious disease epidemic statistics and big data analysis, we can get whether there is intersection of trajectories between each person in time and space.
Now given a group of confirmed person numbers (X1, X2, X3, .... number of people. (Note: The confirmed cases themselves do not need to undergo nucleic acid testing)
The people who need to undergo nucleic acid testing are all the people in the virus transmission chain, that is, all the people to whom the confirmed cases may be transmitted people.
For example: A is a confirmed case, A has contact with B, B has contact with C, C has contact with D, D has contact with E, then B\C\D\E are all People who need nucleic acid testing.

Enter description:

The first line contains the total number of people N

The second line is the number of confirmed cases (number of confirmed cases <N), separated by commas

Starting from the third line, it is an N*N matrix, indicating whether there is contact between each person, 0 means no contact, and 1 means there is contact.

Output description:

Integer: Number of people who need nucleic acid testing

Additional instructions:

Personnel numbers start from 0

0<N<100

Example 1

enter:

5
1,2
1,1,0,1,0
1,1,0,0,0
0,0,1,0,1
1,0,0,1,0
0,0,1,0,1

Output:

3

illustrate:

Persons numbered 1 and 2 are confirmed cases.

No. 1 has contact with No. 0, and No. 0 has contact with No. 3

Guess you like

Origin blog.csdn.net/2301_76848549/article/details/134963698