Hi ,
I solved A1 like everybody else but now I have problems with A2 and A3. My main idea is not that special, try every number for P and generate all possible q and stop if you enter in the circle with map, so that idea is O(N^2) and that is not good. Can anyone help me and say some suggestion for that problem.
Task link
Its solution for a(1,2,3,4,5,6)
Can you give me a little bit more details.
writer of this solution is PrinceOfPersia , you can ask him :)