← All problemsSign in

Constrained Selection

Given a rooted tree consisting of N nodes rooted at node number 1, and a value val[i] associated with each node i. We need to state if it is possible to select a subset of nodes such that if X is the set of selected nodes and Y is the set of not selected nodes, no two nodes a, b should satisfy any of the following properties: - a belongs to X, b belongs to X and val[a]*val[b]%N = 1 - a belongs t

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start