#P3474. [POI2008] KUP-Plot purchase

    ID: 2409 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>单调队列贪心POI2008Special Judge

[POI2008] KUP-Plot purchase

题目描述

Byteasar is going to buy an industrial plot.

His fortune is estimated at bythalers and this is exactly the amount Byteasar would like to spend on the parcel.

Finding a parcel worth exactly bythalers, however, is not an easy task.

For this reason Byteasar is ready to buy a more expensive plot.

He considers taking out a loan. The Byteotian Credit Bank will grant him a loan of up to bythalers. Thus, Byteasar can spend no more than bythalers on the parcel and he would like to spend no less than bythalers.

The area in which Byteasar wants to buy his parcel is a square with side length of metres.

The current landlords have set up various prices per square metre.

Byteasar has spoken to each one of them and has then prepared a price map of the area.

The map depicts the price of every metre by metre square. Clearly, there are such squares.

Now is the time to find the dream parcel.

It has to be rectangular and consist of whole unit squares.

Byteasar has already started looking for the plot on the map, but after many hours he was still unable to find a suitable one.

Be a chap and help him!

Task Write a programme that:

reads the numbers and from the standard input, along with the price map of the area, determines a parcel with price in the interval or states that no such parcel exists, writes out the result to the standard output.

给定k,n,和n*n的矩阵,求一个子矩形满足权值和在[k,2k]之间

n<2000n<2000,1k1091\le k\le10^9,每个价格都是不大于21092*10^9的非负整数

感谢@cn:苏卿念 提供的spj

输入格式

The first line of the standard input contains two integers, and ,
separated by a single space, , .

Each of the following lines contains non-negative integers, separated by single spaces.

number in the line no. denotes the price of unit square with coordinates .

The price of one square metre does not exceed bythalers.

输出格式

If no plot with price in the interval exists, your programme should output exactly one line with word NIE (NO in Polish).

Otherwise it should print out one line with four positive integers separated by single spaces and denoting the rectangle's coordinates.

denotes the upper left rectangle corner, while the lower right corner.

Then it consists of the squares:

.

The sum of prices of the squares forming up this rectangle should satisfy the inequality .

If more than one rectangular parcel satisfies this condition, pick one arbitrarily.

8 4
1 2 1 3
25 1 2 1
4 20 3 3
3 30 12 2
2 1 4 2

提示

n<2000n<2000,1k1091\le k\le10^9,每个价格都是不大于21092*10^9的非负整数