#P10972. I-Country

I-Country

Problem Description

According to the top-secret plan of Country A, Country I is divided into N×MN \times M equal squares, and each square contains some oil resources. They want to occupy the entire territory of Country I, but the United Nations only allows them to occupy KK squares.

Of course, Country A wants to control as much oil as possible, but they must defend all of their territory. Therefore, they need their territory to be easy to control, meaning that from any one square to any other square, you can move only along two directions (chosen from the following list: left, right, up, down; for different pairs of squares, the directions may be different).

You need to write a program to determine which squares Country A will occupy. If there are multiple solutions, you may output any one.

Input Format

The first line contains three integers NN, MM, and KK (1N,M151 \le N, M \le 15, 0KN×M0 \le K \le N \times M).

The next NN lines each contain MM integers, representing the amount of oil resources in each square. Each number ranges from 00 to 10001000.

Output Format

The first line should be the string Oil : X, where XX is the maximum amount of oil that Country A can control.

Then, you should output KK pairs of numbers representing the coordinates of the squares that Country A will occupy. The first number is the row index (from top to bottom, starting from 11), and the second is the column index (from left to right, starting from 11).

2 3 4
10 20 30
40 2 3
Oil : 100
1 1
1 2
1 3
2 1

Hint

Translated by ChatGPT 5