Problem 2: Minimum Turn Route, (K Narayan Kumar, CMI)

The Siruseri amusement park has a new attraction. It consists of a rectangular array of discs. Each disc is divided into four equal sectors and the four sectors are coloured with the colours Red, Blue, Green and Yellow (in some order). The ordering may be different in different discs. Here is a possible arrangment of the discs:

Figure
CPU Timelimit: 3 seconds
Memory limit: 64M
Grading style: ioi
Register Now