Constantine and Mike are playing the board game «Wrath of Elves». There are n races and m classes of characters in this game. Each character is described by his race and class. For each race and each class there is exactly one character of this race and this class. The power of the character of the i-th race and the j-th class equals to aij, and both players know it perfectly.
Now Constantine will choose a character for himself. Before that Mike can ban one race and one class so that Constantine would not be able to choose characters of this race or of this class. Of course, Mike does his best to leave Constantine the weakest possible character, while Constantine, on the contrary, chooses the strongest character. Which race and class Mike should ban?
Input
The first line contains two integers n and m (2 ≤ n, m ≤ 1000) separated by a space — the number of races and classes in the game «Wrath of Elves», correspondingly.
The next n lines contain m integers each, separated by a space. The j-th number in the i-th of these lines is aij (1 ≤ aij ≤ 109).
Output
In the only line output two integers separated by a space — the number of race and the number of class Mike should ban. Races and classes are numbered from one. If there are several possible answers, output any of them.
Examples
Input
2 2
1 2
3 4
Output
2 2
Input
3 4
1 3 5 7
9 11 2 4
6 8 10 12
Output
3 2
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1000005;
struct node {
int x, y, a;
} s[N];
int cmp(node a, node b) { return a.a > b.a; }
int main() {
ios::sync_with_stdio(false);
int n, m, i, j, k = 0, b, c;
cin >> n >> m;
for (i = 1; i <= n; i++) {
for (j = 1; j <= m; j++) {
cin >> c;
s[k].x = i;
s[k].y = j;
s[k++].a = c;
}
}
sort(s, s + k, cmp);
int x = s[0].x;
int y = -1;
for (i = 1; i < k; i++) {
if (y == -1) {
if (s[i].x != x) {
y = s[i].y;
continue;
}
} else {
if (s[i].x != x && s[i].y != y) {
c = s[i].a;
break;
}
}
}
int yy = s[0].y;
int xx = -1;
for (i = 1; i < k; i++) {
if (xx == -1) {
if (s[i].y != yy) {
xx = s[i].x;
continue;
}
} else {
if (s[i].x != xx && s[i].y != yy) {
b = s[i].a;
break;
}
}
}
if (c < b)
cout << x << ' ' << y << '\n';
else
cout << xx << ' ' << yy << '\n';
}
在《Wrath of Elves》这款游戏中,Constantine和Mike进行对决。每种种族和职业都有一个特定的角色,角色的战斗力已知。Mike可以禁用一个种族和一个职业,以使Constantine无法选择这两个。Mike的目标是让Constantine得到最弱的角色。输入包含所有角色的战斗力,输出Mike应该禁用的种族和职业编号,以使Constantine的战斗力最小。程序通过比较角色战斗力来找出最佳策略。

被折叠的 条评论
为什么被折叠?



