1068

// PATn.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include
#include
#include
#include

using namespace std;

vector> get_aboard(unsigned m,unsigned n)
{

    vector> ret;
    
    ret.push_back(make_tuple(m - 1, n - 1));
    ret.push_back(make_tuple(m - 1, n));
    ret.push_back(make_tuple(m - 1, n + 1));
    ret.push_back(make_tuple(m, n - 1));
    ret.push_back(make_tuple(m, n + 1));
    ret.push_back(make_tuple(m + 1, n - 1));
    ret.push_back(make_tuple(m + 1, n));
    ret.push_back(make_tuple(m + 1, n + 1));

    return ret;
}

int main()
{
    unsigned m, n;
    long long tol;
    cin >> m >> n >> tol;

    vector> data;
    for (unsigned i = 0; i < n; ++i)
    {
        vector tmp_row;
        for(unsigned j = 0; j < m; ++j)
        {
            long long tmp;
            cin >> tmp;
            tmp_row.push_back(tmp);
        }
        data.push_back(tmp_row);
    }

    vector> green;
    for (unsigned i = 1; i < (n-1); ++i)
    {
        for (unsigned j = 1; j < (m-1); ++j)    //必须有8个相邻数值!
        {
            bool is_green = true;
            auto tmp = get_aboard(j, i);
            for (auto &r : tmp)
            {
                auto chazhi = abs(data[i][j] - data[get<1>(r)][get<0>(r)]);
                if (chazhi <= tol)//超过的反义词,小于等于!
                {
                    is_green = false;
                    break;
                }   
            }

            if (is_green)
                green.push_back(make_tuple(j, i));      //绿色的坐标值,转换为输出需要加1!
        }
    }

    if (green.size() == 0)
        cout << "Not Exist";
    if (green.size() > 1)
        cout << "Not Unique";
    if (green.size() == 1)
    {
        unsigned i = get<1>(green[0]);
        unsigned j = get<0>(green[0]);
        cout << "("<<(j+1)<<", "<<(i+1)<<"): "<

你可能感兴趣的:(1068)