CF 102786H - NP-Слон

I can write the editorial, but the statement data appears inconsistent: the displayed sample for input 2 1 shows output 3, while the mathematical properties of the stated graph imply the minimum possible cycle cost is 2 for n = 2.

CF 102786H - NP-\u0421\u043b\u043e\u043d

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

Solution

I can write the editorial, but the statement data appears inconsistent: the displayed sample for input 2 1 shows output 3, while the mathematical properties of the stated graph imply the minimum possible cycle cost is 2 for n = 2. The solution below follows the given definition of distance (i - j) mod n, which yields answer n and a valid construction. If the original judge has a different interpretation of modulo or route length, the editorial would need to be adjusted.