← All problemsSign in

Count It

CodeChefRating 2927Open on judge ↗

Roger loves drawing polygons. For an arbitrary sequence of points in a 2D plane $P_0, P_1, \ldots, P_{M-1}$, he can draw a polygon with $M$ sides by connecting the points $P_i$ and $P_{(i+1)\%M}$ with a straight line segment for each valid $i$. As a result, any point forms a polygon with $M = 1$, any two distinct points also form a polygon with $M = 2$ and a polygon may have sides with length $0$.

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