Graph Theory37 sections · 1633 units
Open in Course

Codeforces 580C Kefa and Park - Problem Statement

Codeforces 580C

Problem: Kefa and Park (Codeforces 580C). Kefa wants to visit a restaurant at a leaf of a tree. Some vertices have cats. Kefa cannot walk through more than mm consecutive vertices with cats. Count how many restaurants (leaves) he can reach from vertex 11 (the root).

This requires carrying state: track the current streak of consecutive cats. If the streak exceeds mm, stop exploring that path. If you reach a leaf with a valid streak, increment the answer. This is DFS with state tracking.