一、题目
二、源代码
#include< stdio. h>
#include< math. h>
long t[ 16777216 ] ;
int main ( )
{
int m, n, tol, i, j, count= 0 , x, y;
long color, s[ 1000 ] [ 1000 ] ;
scanf ( "%d %d %d" , & m, & n, & tol) ;
for ( i= 0 ; i< n; i++ )
{
for ( j= 0 ; j< m; j++ )
{
scanf ( "%ld" , & s[ i] [ j] ) ;
t[ s[ i] [ j] ] ++ ;
}
}
for ( i= 0 ; i< n; i++ )
{
for ( j= 0 ; j< m; j++ )
{
if ( t[ s[ i] [ j] ] == 1 )
{
if ( i- 1 >= 0 && j- 1 >= 0 )
{
if ( abs ( s[ i] [ j] - s[ i- 1 ] [ j- 1 ] ) <= tol) continue ;
}
if ( i- 1 >= 0 )
{
if ( abs ( s[ i] [ j] - s[ i- 1 ] [ j] ) <= tol) continue ;
}
if ( i- 1 >= 0 && j+ 1 < m)
{
if ( abs ( s[ i] [ j] - s[ i- 1 ] [ j+ 1 ] ) <= tol) continue ;
}
if ( j- 1 >= 0 )
{
if ( abs ( s[ i] [ j] - s[ i] [ j- 1 ] ) <= tol) continue ;
}
if ( j+ 1 < m)
{
if ( abs ( s[ i] [ j] - s[ i] [ j+ 1 ] ) <= tol) continue ;
}
if ( i+ 1 < n && j- 1 >= 0 )
{
if ( abs ( s[ i] [ j] - s[ i+ 1 ] [ j- 1 ] ) <= tol) continue ;
}
if ( i+ 1 < n)
{
if ( abs ( s[ i] [ j] - s[ i+ 1 ] [ j] ) <= tol) continue ;
}
if ( i+ 1 < n && j+ 1 < m)
{
if ( abs ( s[ i] [ j] - s[ i+ 1 ] [ j+ 1 ] ) <= tol) continue ;
}
count++ ;
x= j+ 1 ;
y= i+ 1 ;
color= s[ i] [ j] ;
}
}
}
if ( count== 0 ) printf ( "Not Exist\n" ) ;
else if ( count== 1 ) printf ( "(%d, %d): %ld\n" , x, y, color) ;
else printf ( "Not Unique\n" ) ;
return 0 ;
}
三、运行结果