← All problemsSign in

Queen of Hearts

CodeChefRating 2992Open on judge ↗

Wonderland is a wonderful world inhabited by N strange creatures, for simplicity all creatures are numbered from 1 to N. Every creature has exactly one best friend (it could be himself too). Note that, the friendship relationship is not bidirectional, meaning that it might be the case person x is best friend of y, but y is not best friend of x. Besides that, there is a very intricate admiration re

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