CF1288D.Minimax Problem

普及+/提高

通过率:0%

时间限制:5.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

You are given nn arrays a1a_1, a2a_2, ..., ana_n; each array consists of exactly mm integers. We denote the yy-th element of the xx-th array as ax,ya_{x, y}.

You have to choose two arrays aia_i and aja_j (1≤i,j≤n1 \le i, j \le n, it is possible that i=ji = j). After that, you will obtain a new array bb consisting of mm integers, such that for every k∈[1,m]k \in [1, m] bk=max⁡(ai,k,aj,k)b_k = \max(a_{i, k}, a_{j, k}).

Your goal is to choose ii and jj so that the value of min⁡k=1mbk\min \limits_{k = 1}^{m} b_k is maximum possible.

给你 nn 个数组 a1a_1, a2a_2, ..., ana_n;每个数组恰好包含 mm 个整数。我们用 ax,ya_{x, y} 表示第 xx 个数组的第 yy 个元素。

你需要选择两个数组 aia_i 和 aja_j(其中 1≤i,j≤n1 \le i, j \le n,允许 i=ji = j)。然后,你将得到一个由 mm 个整数组成的新数组 bb,其定义为:对每个 k∈[1,m]k \in [1, m],有 bk=max⁡(ai,k,aj,k)b_k = \max(a_{i, k}, a_{j, k})。

你的目标是选择 ii 和 jj,使得 min⁡k=1mbk\min \limits_{k = 1}^{m} b_k 的值尽可能大。

输入格式

The first line contains two integers nn and mm (1≤n≤3⋅1051 \le n \le 3 \cdot 10^5, 1≤m≤81 \le m \le 8) — the number of arrays and the number of elements in each array, respectively.

Then nn lines follow, the xx-th line contains the array axa_x represented by mm integers ax,1a_{x, 1}, ax,2a_{x, 2}, ..., ax,ma_{x, m} (0≤ax,y≤1090 \le a_{x, y} \le 10^9).

第一行包含两个整数 nn 和 mm(1≤n≤3⋅1051 \le n \le 3 \cdot 10^5,1≤m≤81 \le m \le 8),分别表示数组的个数以及每个数组的元素个数。

接下来是 nn 行,其中第 xx 行包含由 mm 个整数 ax,1a_{x, 1}、ax,2a_{x, 2}、…、ax,ma_{x, m}(0≤ax,y≤1090 \le a_{x, y} \le 10^9)表示的数组 axa_x。

输出格式

Print two integers ii and jj (1≤i,j≤n1 \le i, j \le n, it is possible that i=ji = j) — the indices of the two arrays you have to choose so that the value of min⁡k=1mbk\min \limits_{k = 1}^{m} b_k is maximum possible. If there are multiple answers, print any of them.

输出两个整数 ii 和 jj(1≤i,j≤n1 \le i, j \le n,允许 i=ji = j)——即你需要选择的两个数组的下标,使得 min⁡k=1mbk\min \limits_{k = 1}^{m} b_k 的值尽可能大。如果存在多个满足条件的答案,输出任意一个即可。

输入输出样例

  • 输入#1

    6 5
    5 0 3 1 2
    1 8 9 1 3
    1 2 3 4 5
    9 1 0 3 7
    2 3 0 6 3
    6 4 1 7 0

    输出#1

    1 5

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

首页