Color Cubes Advanced

Problem #147

Tags: games challenge

This task has a Challenge attached.
You may View Stats or read a Help on Challenges.

Click the areas of the same colors to remove them. Try to achieve maximum points!


It is recommended to solve Color Cubes at first to get the understanding of the game rules.

Here is the same game of Color Cubes, but the field is larger. You (and other contestants) are given some initial setup of the blocks and the goal is to find the sequence of moves leading to the highest score.

Input data are the same for all contestants.
They will contain the size of the box N in the first line (somewhere between 100 and 150).
Next N lines contain N digits each (from 1 to 4) describing colors of the squares.
Answer should contain pairs of coordinates for moves separated only with spaces i.e. X0 Y0 X1 Y1 X2 Y2 .... Note that 0 0 is at the bottom left corner!

You may use this test page to visualize the work of your solution.

Scoring There is some reasonable limit of points below which your answer is not accepted. If your score is above this limit the result is calculated as

result = score / limit - 1

(and then multiplied by the challenge coefficient)

You need to login to get test data and submit solution.