Black Nodes in Subgraphs
CodeChefOpen on judge ↗
You are given a tree T with N nodes. The nodes are numbered from 1 to N, and each node is colored either white or black. You are given Q queries, where each query is of the form (s, b). You need to check if there is a connected subgraph of size exactly s, which contains exactly b black nodes. A subgraph H, of a tree T, is a graph whose vertex set VH is a subset of the nodes of the tree and the ed
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start