注意:
1.对于边缘的测试
2.对唯一性的确定(颜色数值太大,不能用数组确定唯一性,要用map来确定了,否则可以把颜色值作为数组下标,统计各颜色值的个数)
#include<iostream>
#include<map>
using namespace std;
int m,n,e,f,cnt=0,s[10000][10000]={0},tol;
int turn(int a,int b){
for(int x=(a==1?a:a-1);x<=(a==n?a:a+1);x++)
for(int y=(b==1?b:b-1);y<=(b==m?b:b+1);y++)
if(!(a==x&&b==y)&&s[a][b]-s[x][y]<=tol&&s[a][b]-s[x][y]>=-tol)return 0;
return 1;
}
int main(){
map<int,int> mp;
cin>>m>>n>>tol;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>s[i][j];
mp[s[i][j]]++;
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(turn(i,j)==1&&mp[s[i][j]]==1){
e=i;f=j;
cnt++;
}
}
}
if(cnt>1)cout<<"Not Unique";
else if(cnt==0)cout<<"Not Exist";
else cout<<'('<<f<<", "<<e<<"): "<<s[e][f];
return 0;
}