PJ and Snake
CodeChefOpen on judge ↗
PJ and his friend, AJ are having a walk in a square field of size N x N. A snake bites AJ at position (N,1) [1-based indexing] and tries to escape; it moves inside the field in a special manner. PJ being quite intellegent, manages to predict where the snake will be at any given point in time. The pattern below shows how the snake will move in a 4x4 field. The values in each position are the numbe
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.
Sign in to chat with the tutor and save your progress.
Sign in to start