Path Triples On Tree
Chef is given a tree of N nodes. Let M denote the number of simple paths with at least two nodes. Notice that M = N * (N - 1) / 2. There are (M * (M - 1) * (M - 2) / 6) unordered triples of such paths. Your task is to count how many of them are nice. A triple of paths (A, B, C) is nice if and only if either of the following conditions is satisfied: - The three paths are pairwise disjoint (no
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