CHEF AND INFINITE GRID
CodeChefOpen on judge ↗
Chef is standing at a point (a,b) in an $infinite$ grid. The only operation he can do is to move to point (a+b,b) ,(a,a+b) ,(a-b,b) and (a,b-a). Now he asks you $Q$ queries. In each query he gives a coordinate (x,y) and asks you if he can reach that coordinate from his current coordinate. If yes, then he $move$ to (x,y) else he stays at his current coordinate. $Note:$ - Suppose Chef moves in some
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