|시간 제한||메모리 제한||제출||정답||맞힌 사람||정답 비율|
|1 초||128 MB||9||6||6||66.667%|
A national election will be held in the JOI kingdom. The JOI kingdom consists of N provinces.
The map of the JOI kingdom is a rectangular-shaped grid consisting of H ×W blocks. There are H blocks in the vertical direction, and there are W blocks in the horizontal direction. A block is connected with another block by one of the four sides (left, right, top, bottom) of it. The H × W blocks are divided into N provinces. Each province is a connected region consisting of blocks. In total, there are Pi voters in the i-th province (1 ≤ i ≤ N).
You are the chairman of the National Election Committee of JOI. Your task is to divide the N provinces into K electoral districts (1 ≤ K ≤ N) in order to elect K representatives. Each electoral district should contain at least one province, and the blocks belonging to an electoral district should form a connected region. Note that a block is connected with another block by one of the four sides (left, right, top, bottom). Two blocks sharing only a vertex are not connected.
For each electoral district, the ratio 1/(the number of voters in the electoral district) is called the weight of a single vote of the electoral district. The vote-value disparity is defined to be the maximal weight of a single vote for all electoral districts divided by the the minimal weight of a single vote for all electoral districts.
Recently, the value of “the vote-value disparity” becomes a serious social issue. You have to make this value as small as possible.
Given the information of the provinces of the JOI kingdom and the number of representatives, determine how to divide the provinces into electoral districts so that the value of the vote-value disparity is as small as possible.
Read the following data from the standard input.
Write the way to divide the provinces into electoral districts in N lines. The i-th line (1 ≤ i ≤ N) of output should contain an integer, the number of the electoral district where the i-th province belongs.
For each input, your score is calculated as follows.
If your output does not satisfy the condition in the task statement, your score is 0. If it satisfies the condition, let D denote the vote-value disparity of your output. Then your score is calculated by the following way.
The values of X, Y are given in the following table.
2 3 4 3 1 1 1 2 3 4 3 5 7 10
1 2 1 3
In this example, the shape of the JOI kingdom is as follows.
The number of voters in each province is 3, 5, 7, 10, respectively. In this sample output, the provinces are divided into electoral districts as follows.
The number of voters in each electoral district is 10, 5, 10, respectively. The weight of a single vote for each electoral district is 0.1, 0.2, 0.1, respectively. Therefore, the vote-value disparity is 0.2/0.1 = 2. If X = 1.5, Y = 3, we have ((3−2)/(3−1.5))2 × 100 = 44.4444444444··· and this output is worth 44.4444444444··· points.
In this sample input, the following division is not allowed because the Electoral District 2 does not form a connected region.