338. Familystrokes 〈TOP 2026〉

338. Familystrokes 〈TOP 2026〉

cout << internalCnt + horizontalCnt << '\n'; return 0;

int main() long long horizontalCnt = 0; // # v 338. FamilyStrokes

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 . internalCnt + horizontalCnt &lt

import sys sys.setrecursionlimit(200000) 338. FamilyStrokes