CF 105572C - Сквайр Трелони

The problem statement for “Codeforces 105572C - Сквайр Трелони” is not included in your message, so I can’t reliably reconstruct the task or derive a correct solution.

CF 105572C - \u0421\u043a\u0432\u0430\u0439\u0440 \u0422\u0440\u0435\u043b\u043e\u043d\u0438

Rating: -
Tags: -
Solve time: 29s
Verified: no

Solution

The problem statement for “Codeforces 105572C - Сквайр Трелони” is not included in your message, so I can’t reliably reconstruct the task or derive a correct solution.

For a Codeforces editorial, the exact input/output definition and constraints matter heavily, since even small differences change the algorithm completely. Without that, anything I write would risk being wrong or unrelated to the actual problem.

Please paste the full problem statement (or at least the Input/Output description and constraints), and I’ll produce a complete editorial in the exact format you requested.