You are given nnn arrays a1,a2,...,ana_1, a_2, ..., a_na1​,a2​,...,an​; each array consists of exactly mmm integers. We denote the yyy-th element of the xxx-th array as ax,ya_{x,y}ax,y​.

You have to choose two arrays aia_iai​ and aja_jaj​ (1≤i,j≤n1≤i,j≤n1≤i,j≤n, it is possible that i=ji=ji=j). After that, you will obtain a new array bbb consisting of m integers, such that for every k∈[1,m]k∈[1,m]k∈[1,m] bk=max(ai,k,aj,kb_k=max(a_{i,k},a_{j,k}bk​=max(ai,k​,aj,k​).

Your goal is to choose iii and jjj so that the value of min⁡k=1mbk\min \limits_{k = 1}^{m} b_kk=1minm​bk​ is maximum possible.

Input

The first line contains two integers nnn and mmm (1≤n≤3⋅105,1≤m≤81≤n≤3⋅10^5, 1≤m≤81≤n≤3⋅105,1≤m≤8) — the number of arrays and the number of elements in each array, respectively.

Then nnn lines follow, the xxx-th line contains the array axa_xax​ represented by mmm integers ax,1,ax,2,...,ax,ma_{x,1}, a_{x,2}, ..., a_{x,m}ax,1​,ax,2​,...,ax,m​ (0≤ax,y≤1090≤ax,y≤1090≤ax,y≤109).

Output

Print two integers iii and jjj (1≤i,j≤n1≤i,j≤n1≤i,j≤n, it is possible that i=ji=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_kk=1minm​bk​ is maximum possible. If there are multiple answers, print any of them.

Example

input

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

output

1 5

最小值最大化问题,绝大概率是二分。但是二分之后的judge环节怎么弄呢?这就是本题的出彩之处。我们将每一个数组中的大于等于mid的位置设置为1,否则就设置为0。这样我们进行或操作,这样出来的就是取最大值操作了。这样如果两两相或,如果各个位上都是1,就代表着当前的mid就是最小值,然后不断的二分,就可以找到最优解了。

#include <bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
int a[maxn][10];
int n,m,x,y;
int vis[390];
int check(int mid) {memset(vis, 0, sizeof(vis));for (int i = 1; i <= n; i++) {int k = 0;for (int j = 0; j < m; j++) {if (a[i][j] >= mid) k |= (1 << j);}vis[k] = i;}for (int i = 0; i <= 255; i++) {for (int j = 0; j <= 255; j++) {if (vis[i] && vis[j] && (i | j) == (1 << m) - 1) {x = vis[i];y = vis[j];return 1;}}}return 0;
}
int main() {scanf("%d%d", &n, &m);for (int i = 1; i <= n; i++) {for (int j = 0; j < m; j++) {scanf("%d", &a[i][j]);}}int l = 0, r = 1e9;while (l <= r) {int mid = l + r >> 1;if (check(mid)) l = mid + 1; else r = mid - 1;}printf("%d %d\n", x, y);return 0;
}

Minimax Problem相关推荐

  1. CodeForces - 1288D Minimax Problem(二分+状态压缩)

    题目链接:点击查看 题目大意:给出一个n*m的矩阵,我们用maze[n][m]来表示每一个元素,现在我们需要选出其中 i 和 j 两行,i 和 j 可以相同,用这两行的元素构成一个新的数组a,构造规则 ...

  2. Minimax Problem(二分+二进制状态压缩)

    You are given n arrays a1, a2, -, an; each array consists of exactly m integers. We denote the y-th ...

  3. BAAI 2020 北京智源大会 | 戴彧虹 | Optimality Conditions for Constrained Minimax Optimization

    Optimality Conditions for Constrained Minimax Optimization 回放地址 报告内容 概述 Part Ⅰ Background for Minima ...

  4. Educational Codeforces Round 80 (Rated for Div. 2)SZU cf集训round2 C~E(dp,状压+二分,树状数组+逆向思维)

    C. Two Arrays 题目大意:就是给定两个整数n和m.计算数组对的数量(a,b),使得: 1 .两个阵列的长度都等于m: 2 .每个数组的每个元素都是1到n(包括1和n)之间的整数: 从1到m ...

  5. 提高篇 第五部分 动态规划 第4章 状态压缩类动态规划

    例1 骑士(Sgu223) 1592:[例 1]国王 信息学奥赛一本通(C++版)在线评测系统 https://blog.csdn.net/guoyangfan_/article/details/82 ...

  6. 对抗机器学习(Adversarial Machine Learning)发展现状

    目录 1. 了解对手 1. 1 攻击目标(Goal) 1. 2 知识储备(Knowledge) 1.3 能力限制(Capability) 1.4 攻击策略(Strategy) 2. 学会主动 2.1 ...

  7. GANs学习系列(2):GANs最新进展二

    reference:http://blog.csdn.net/solomon1558/article/details/52338052 文献整理 题目 主要内容                     ...

  8. GAN生成对抗网络论文翻译(一)

    给自己一个动力去看英语论文,每天翻译一节,纯属自己翻译,小白一只,如果您能提出建议或者翻译修改,将非常感谢,首先谢谢! How Generative Adversarial Networks and ...

  9. 2020年 ICLR 国际会议最终接受论文(poster-paper)列表(一)

    来源:AINLPer微信公众号(点击了解一下吧) 编辑: ShuYini 校稿: ShuYini 时间: 2020-01-22     2020年的ICLR会议将于今年的4月26日-4月30日在Mil ...

  10. Low-Rank Solution of Lyapunov Equations(一)ADI算法

    Abstract. This paper presents the Cholesky factor–alternating direction implicit (CF–ADI) algorithm, ...

最新文章

  1. 京东玩三角恋,结果“擦枪走火”
  2. 关于ubuntu-12.04.4-server-i386安装的问题
  3. Django 3.2.5博客开发教程:实现模板之前的分析与准备
  4. Boost:boost::asio模块的allocation service分配服务测试程序
  5. 创建react应用程序_使用SpringWebFlux的React式Web应用程序
  6. Matlab查看数组大小的命令——size、length、numel和ndims
  7. 关于xcode6打包以及上线前企业部署测试的说明 --转自张诚教授微博
  8. 我悄悄地把cocos2d-x占了
  9. EnableDebugPriv;
  10. P11:经典卷积神经网络结构案例分析
  11. 狼来了!第一批90后测试员已经开始经历测试行业求职危机……
  12. mac 下 sublime text 运行c++/c 不能使用scanf/cin
  13. C# 中使用反射的优缺点
  14. 最新最全 VSCODE 插件推荐(2022版)
  15. cad剖切线的快捷键_cad快捷键(最全CAD快捷键大全 )
  16. 统计学与概率论的区别
  17. 20个免费论文下载入口_含免费知网、万方、维普帐号
  18. 关于组织自定义皮肤/主题的一点思考
  19. pytorch-YOLOv3移植到寒武纪
  20. java操作RabbitMQ

热门文章

  1. 《大数据之路:阿里巴巴大数据实践》-第1篇 数据技术篇 -第3章数据同步
  2. Unity3d 发动机原理详细介绍
  3. delphi计算机语言排名,2020年3月TIOBE编程语言排行榜 Java继续蝉联榜首
  4. 参考文献格式字号字体_参考文献用什么字体字号 参考文献标准格式字体
  5. JavaScript提示框
  6. [精品]CAD批量处理工具
  7. 共享计算机无法打开文件,Windows7局域网无法打开共享文件分析
  8. 反转链表 c++实现
  9. 萤石云摄像头Http接口云台控制开发
  10. 教你如何批量下载QQ相册或是手机相册里原照片