mirror of
https://github.com/xlucn/PAT.git
synced 2026-11-05 06:37:35 +08:00
28 lines
4.5 KiB
HTML
28 lines
4.5 KiB
HTML
The Largest Generation
|
|
<div class="ques-view"><p>A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest population.</p>
|
|
<h3 id="input-specification-">Input Specification:</h3>
|
|
<p>Each input file contains one test case. Each case starts with two positive integers <span class="katex"><span class="katex-mathml"><math><mrow><mi>N</mi></mrow>N</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.68333em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.10903em;">N</span></span></span></span> (<span class="katex"><span class="katex-mathml"><math><mrow><mo><</mo><mn>1</mn><mn>0</mn><mn>0</mn></mrow><100</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.64444em;"></span><span class="strut bottom" style="height:0.68354em;vertical-align:-0.0391em;"></span><span class="base textstyle uncramped"><span class="mrel"><</span><span class="mord mathrm">1</span><span class="mord mathrm">0</span><span class="mord mathrm">0</span></span></span></span>) which is the total number of family members in the tree (and hence assume that all the members are numbered from 01 to <span class="katex"><span class="katex-mathml"><math><mrow><mi>N</mi></mrow>N</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.68333em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.10903em;">N</span></span></span></span>), and <span class="katex"><span class="katex-mathml"><math><mrow><mi>M</mi></mrow>M</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.68333em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.10903em;">M</span></span></span></span> (<span class="katex"><span class="katex-mathml"><math><mrow><mo><</mo><mi>N</mi></mrow><N</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.72243em;vertical-align:-0.0391em;"></span><span class="base textstyle uncramped"><span class="mrel"><</span><span class="mord mathit" style="margin-right:0.10903em;">N</span></span></span></span>) which is the number of family members who have children. Then <span class="katex"><span class="katex-mathml"><math><mrow><mi>M</mi></mrow>M</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.68333em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.10903em;">M</span></span></span></span> lines follow, each contains the information of a family member in the following format:</p>
|
|
<pre><code>ID K ID[1] ID[2] ... ID[K]
|
|
</code></pre><p>where <code>ID</code> is a two-digit number representing a family member, <code>K</code> (<span class="katex"><span class="katex-mathml"><math><mrow><mo>></mo><mn>0</mn></mrow>>0</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.64444em;"></span><span class="strut bottom" style="height:0.68354em;vertical-align:-0.0391em;"></span><span class="base textstyle uncramped"><span class="mrel">></span><span class="mord mathrm">0</span></span></span></span>) is the number of his/her children, followed by a sequence of two-digit <code>ID</code>'s of his/her children. For the sake of simplicity, let us fix the root <code>ID</code> to be <code>01</code>. All the numbers in a line are separated by a space.</p>
|
|
<h3 id="output-specification-">Output Specification:</h3>
|
|
<p>For each test case, print in one line the largest population number and the level of the corresponding generation. It is assumed that such a generation is unique, and the root level is defined to be 1.</p>
|
|
<h3 id="sample-input-">Sample Input:</h3>
|
|
<pre><code class="lang-in">23 13
|
|
21 1 23
|
|
01 4 03 02 04 05
|
|
03 3 06 07 08
|
|
06 2 12 13
|
|
13 1 21
|
|
08 2 15 16
|
|
02 2 09 10
|
|
11 2 19 20
|
|
17 1 22
|
|
05 1 11
|
|
07 1 14
|
|
09 1 17
|
|
10 1 18
|
|
</code></pre>
|
|
<h3 id="sample-output-">Sample Output:</h3>
|
|
<pre><code class="lang-out">9 4
|
|
</code></pre>
|
|
</div> |