ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 2116. He is not a knight for you

Solution (SPOILER)
Posted by Alikhan Zimanov 14 Jan 2021 16:50
Let's consider the case a = 0 and b = 0. Obviously, the answer will be n * n, because none of the knights will be able to move to any other cell of the table. Now let's assume that a != 0 or b != 0. By doing some casework, one can show that the answer for n will be the same as the answer for min(n, 10), so we can assume that n <= 10. Then, just find all possible night moves and get connected components of the corresponding graph. The answer will be the number of connected components.