You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.0 KiB
44 lines
1.0 KiB
|
|
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
const int N = 101;
|
|
int a[N][N] = {0};
|
|
|
|
int main() {
|
|
//输入+输出重定向
|
|
freopen("../friend.in", "r", stdin);
|
|
freopen("../friend.out", "w", stdout);
|
|
|
|
int m, n, x, y;
|
|
cin >> m >> n >> x >> y;
|
|
|
|
for (int i = 1; i <= m; i++) {
|
|
for (int j = 1; j <= n; j++) {
|
|
cin >> a[i][j];
|
|
}
|
|
}
|
|
|
|
int bestx = INT32_MAX, besty = INT32_MAX, bestDis = INT32_MAX;
|
|
for (int i = 1; i <= m; i++) {
|
|
for (int j = 1; j <= n; j++) {
|
|
if (i == x && j == y) continue;//自己和自己不能称为好朋友
|
|
if (a[x][y] == a[i][j]) {
|
|
int dis = abs(i - x) + abs(j - y);
|
|
if (dis < bestDis) {
|
|
bestDis = dis;
|
|
bestx = i;
|
|
besty = j;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
cout << bestx << " " << besty << endl;
|
|
|
|
//关闭文件
|
|
fclose(stdin);
|
|
fclose(stdout);
|
|
return 0;
|
|
} |