[Solution] Largest Family Codechef Solution
A certain parallel universe has exactly people living in it.
The -th of these people claims that they are the parent of exactly of these people.
However, some of these people might be lying — the -th person may be either telling the truth (in which case they have exactly children) or lying (in which case they can have any number of children).
It is known that each person has at most one parent. Further, as one would expect, it is not allowed for a person's child to also be their ancestor.
What is the maximum possible number of truth-tellers in
👇👇👇👇👇
this universe?
Input Format
- The first line of input will contain a single integer , denoting the number of test cases.
- Each test case consists of two lines of input.
- The first line of each test case contains a single integer , the number of people.
- The second line of each test case contains space-separated integers .
Output Format
For each test case, output on a new line the maximum number of people that can be telling the truth.
No comments:
Post a Comment