
 73通过
 261提交
 题目提供者 洛谷
 评测方式 云端评测
 标签 单调队列 贪心 POI 2008 Special Judge
 难度 省选/NOI
 时空限制 1000ms / 128MB
最新讨论 显示
题目描述
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]之间
感谢@cn：苏卿念 提供的spj
输入输出格式
输入格式：The first line of the standard input contains two integers, and , separated by a single space, , .
Each of the following lines contains nonnegative 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:
![](http://main.edu.pl/images/OI15/kupentex.25.png).
The sum ![](http://main.edu.pl/images/OI15/kupentex.26.png) of prices of the squares forming up this rectangle should satisfy the inequality ![](http://main.edu.pl/images/OI15/kupentex.27.png).
If more than one rectangular parcel satisfies this condition, pick one arbitrarily.