## A modern art

 Time limit: - MS    Space limitations: 165536 KB Benchmark description: 1s
###### Problem Description

What the boss is a modernist artist. His paintings on canvas made of an n * n squares. At first, possessive house numbers are 0.
What the boss painting unique manner, he has to N ^ 2 sub-matrix color painted, each time from 1 to N ^ 2 These figures correspond to a selected fill all of the digital matrix. For example:
The first step, he chose to fill in the number 2 on a sub-matrix. As shown below:

```2 2 2 0
2 2 2 0
2 2 2 0
0 0 0 0
Step 2, he figures 7 to fill in a sub Matrices:
2 2 2 0
2 7 7 7
2 7 7 7
0 0 0 0
3 step, he filled in with the number 3 on a sub-matrix:
2 3 2 0
2. 7. 7 3
2. 7. 7. 7
0 0 0 0
in this Tiantu continues until the N ^ 2 1 to each number are used once (each number can only be used once).
Now what the boss has completed his art, you get the final graphics.
What the boss ask you, based on the painting, you can infer the first step Tiantu numbers may be, what does? The first step in digital output Tiantu possible number.
```
###### Input Format

The first line, an integer N (1 <= N <= 1000)
Next, a number N * N matrix representing the final look paintings.

###### Output Format

An integer that represents the first step Tiantu possible number of digits.

4
2 2 3 0
2 7 3 7
2 7 7 7
0 0 0 0

14

###### prompt

Sample explanation, the number 2 is the first to be Tiantu. Obviously the number 3 after Tiantu at number 7, number seven in number 2 after apparently Tiantu.
Not see the other numbers, so these figures are likely to appear before the number 2, was later covered.

### Guess you like

Origin www.cnblogs.com/Limbo-To-Heaven/p/11407954.html
Recommended
Ranking
Daily