Alternating Colored Paths
CodeChefOpen on judge ↗
Given a tree of size N with each vertex colored either black or white. Find the number of paths with alternating colors. Input First line will have N, the number of vertices of the tree and then N-1 lines will follow of the form u v which denotes an edge between the vertex u and v. Finally, the next line will contain the space separated color(either W for white or B for Black) of each vertex. O
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