[BZOJ1127] [POI2008] Kup Sub-matrix

Source: Internet
Author: User

Description

Give a n*n map, each lattice has a price, find a rectangular area so that its price sum is located in [k,2k]


Input

Enter K N (n<2000) and a map of n*n


Output

The upper-left and lower-right columns of the output rectangle-line coordinates or NIE

Sample Input

4 3
1 1 1
1 9 1
1 1 1
inputdata2
1 2 1 3
25 1 2 1
4 3 3
3 2


Sample Output

Outputdata1
NIE
Outputdata2
2 1 4 2

The puzzle (from the author):

  If there is a[i,j]∈[k,2k] direct output. Otherwise, the point of a[i,j]>2k is regarded as an obstacle, and a recursive f[i,j] means that there is no obstacle in the continuous section from I,j to left, and similar g[i,j] indicates the length to the right. Because of the a[i,j]<k, the neighboring prefixes and the impossibility from <k into >2k. So if there is s[i,l. R]>2K is bound to exist s[i,l. P]∈[K,2K], the F value is determined if there is s[i,j-f[i,j]+1..j]∈[k,2k]. Otherwise we use f and g to find the maximal and sub-matrix Smax (classical algorithm, not repeat). If the smax<k is no solution, otherwise there must be Smax prefix and ∈[k,2k].

[BZOJ1127] [POI2008] Kup Sub-matrix

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.