338. Familystrokes May 2026

while (!st.empty()) int v = st.back(); st.pop_back(); int childCnt = 0; for (int to : g[v]) if (to == parent[v]) continue; parent[to] = v; ++childCnt; st.push_back(to); if (childCnt > 0) ++internalCnt; if (childCnt >= 2) ++horizontalCnt;

Memory – The adjacency list stores 2·(N‑1) integers, plus a stack/queue of at most N entries and a few counters: O(N) . 338. FamilyStrokes

if childCnt > 0: // v has at least one child → internal internalCnt += 1 if childCnt >= 2: horizontalCnt += 1 while (

Only‑if childCnt = 1 : the sole child is placed directly under the parent; the horizontal segment would have length zero and is omitted by the drawing convention. ∎ The number of strokes contributed by a node v is By definition a leaf has no children, thus

internalCnt ← 0 // |I| horizontalCnt ← 0 // # childCount(v) ≥ 2

Proof. By definition a leaf has no children, thus rule 1 (vertical stroke) and rule 2 (horizontal stroke) are both inapplicable. ∎ Every internal node (node with childCnt ≥ 1 ) requires exactly one vertical stroke .

 

 

 

Technické řešení © 2026 CyberSoft s.r.o.

 
 
 

K provozování našeho webu www.wifihw.cz využíváme takzvané cookies. Cookies jsou soubory sloužící k přizpůsobení obsahu webu, k měření jeho funkčnosti a obecně k zajištění vaší maximální spokojenosti. Používáním tohoto webu souhlasíte se způsobem, jakým s cookies nakládáme.