← All problemsSign in

Lucky Edge

CodeChefRating 2928Open on judge ↗

In an undirected unweighted graph, an edge of the graph is said to be lucky if it is a part of some cycle of the graph. You are given a list E of M edges. We define f(i) as the number of intervals [l, r] (1 ≤ l ≤ i ≤ r ≤ M) such that if you build a graph from edges El, El+1, ..., Er, the edge Ei will be a lucky edge in this graph. Your task is to calculate the values of f(1), f(2), ..., f(M).

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