← All problemsSign in

Sacred cows

Farmer John's has N cows in his farmhouse , numbered from $1$ to $N$. The $i$-th cow in his farm likes cow $C_i$ (1<=i<=N). No cow likes itself , that is $C_i ≠ i$. For a pair of cows $i$ and $j$ (i< j), we call the pair of cows (i,j) a sacred pair if : - If cow $i$ likes cow $j$ and cow $j$ likes cow $i$. Your task is to Calculate the number of sacred pairs. ###Input: - The first line cont

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