#include <iostream>
#include <cstring>
using namespace std;
const int N = 1010;
int n, m, t;
long long g[N][N];
long long used[100000010];
bool check(int x, int y)
{
for (int i = x - 1; i <= x + 1; i ++)
for (int j = y - 1; j <= y + 1; j ++)
{
if (g[i][j] == -1) continue;
if (i == x && y == j) continue;
if (abs(g[x][y] - g[i][j]) <= t) return false;
}
return true;
}
int main()
{
cin >> m >> n >> t;
memset(g, -1, sizeof g);
for (int i = 1; i <= n; i ++)
for (int j = 1; j <= m; j ++)
{
cin >> g[i][j];
used[g[i][j]] ++;
}
int cnt = 0;
int x = 0, y = 0;
for (int i = 1; i <= n; i ++)
for (int j = 1; j <= m; j ++)
{
if (check(i, j) && used[g[i][j]] == 1)
{
cnt ++;
x = i, y = j;
}
}
if (cnt > 1) cout << "Not Unique";
else if (cnt) printf("(%d, %d): %d\n",y, x, g[x][y]);
else cout << "Not Exist";
return 0;
}
【PAT】1068 万绿丛中一点红 (20 分)
最新推荐文章于 2022-11-20 15:53:55 发布