CF1423M.Milutin's Plums

省选/NOI-

通过率:0%

时间限制:1.00s

内存限制:1024MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

As you all know, the plum harvesting season is on! Little Milutin had his plums planted in an orchard that can be represented as an nn by mm matrix. While he was harvesting, he wrote the heights of all trees in a matrix of dimensions nn by mm.

At night, when he has spare time, he likes to perform various statistics on his trees. This time, he is curious to find out the height of his lowest tree. So far, he has discovered some interesting properties of his orchard. There is one particular property that he thinks is useful for finding the tree with the smallest heigh.

Formally, let L(i)L(i) be the leftmost tree with the smallest height in the ii-th row of his orchard. He knows that L(i)≤L(i+1)L(i) \le L(i+1) for all 1≤i≤n−11 \le i \le n - 1. Moreover, if he takes a submatrix induced by any subset of rows and any subset of columns, L(i)≤L(i+1)L(i) \le L(i+1) will hold for all 1≤i≤n′−11 \le i \le n'-1, where n′n' is the number of rows in that submatrix.

Since the season is at its peak and he is short on time, he asks you to help him find the plum tree with minimal height.

众所周知,李子采摘季到了!小米卢廷在他的果园里种了李子树,该果园可以表示为一个 nn 行 mm 列的矩阵。在采摘过程中,他将每棵树的高度记录在一个 nn 行 mm 列的矩阵中。

夜晚闲暇时,他喜欢对他的果树进行各种统计分析。这一次,他想找出自己果园中高度最低的那棵树。到目前为止,他已发现果园具有一些有趣的性质。其中有一条性质,他认为对寻找最矮的树特别有用。

形式化地,令 L(i)L(i) 表示第 ii 行中最矮树中最靠左的那一棵的位置(即列索引)。他已知对所有 1≤i≤n−11 \le i \le n - 1,均有 L(i)≤L(i+1)L(i) \le L(i+1)。此外,若任取若干行与若干列构成一个子矩阵,则在该子矩阵中,对任意 1≤i≤n′−11 \le i \le n'-1(其中 n′n' 为该子矩阵的行数),仍有 L(i)≤L(i+1)L(i) \le L(i+1) 成立。

由于采摘季正值高峰,他时间紧迫,因此请你帮助他找出高度最小的李子树。

输入格式

This problem is interactive.

The first line of input will contain two integers nn and mm, representing the number of rows and the number of columns in Milutin's orchard. It is guaranteed that 1≤n,m≤1061 \le n, m \le 10^6.

The following lines will contain the answers to your queries.

本题为交互式问题。

输入的第一行包含两个整数 nn 和 mm,分别表示米卢廷果园的行数和列数。保证 1≤n,m≤1061 \le n, m \le 10^6。

接下来的若干行将包含对你所提出查询的响应。

输出格式

Once you know have found the minimum value rr, you should print ! rr to the standard output.

一旦你找到了最小值 rr,你应该向标准输出打印 ! $r$。

输入输出样例

  • 输入#1

    5 5
    13 15 10 9 15
    15 17 12 11 17
    10 12 7 6 12
    17 19 14 13 19
    16 18 13 12 18

    输出#1

输入解题思路,AI测评打分。不知道怎么写?

首页