1068

作者: 峡迩 | 来源:发表于2017-09-05 16:06 被阅读0次
// PATn.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include<iostream>
#include<string>
#include<vector>
#include<tuple>

using namespace std;

vector<tuple<unsigned, unsigned>> get_aboard(unsigned m,unsigned n)
{

    vector<tuple<unsigned, unsigned>> 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<vector<long long>> data;
    for (unsigned i = 0; i < n; ++i)
    {
        vector<long long> 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<tuple<unsigned, unsigned>> 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)<<"): "<<data[i][j];
    }

    system("pause");
    return 0;
}

相关文章

  • 1068

  • 1068

    8月28日,农历八月初二,多云,周日 今天居然是周日,没有一点点周末的感觉哈!连上三天班,后面还有五天,一共连上八...

  • POJ - 1068

  • 日记1068

    2022年11月21日 星期一 阴 今天工作是相当好繁琐忙碌,所以嗓子瞬间疼痛、肿大,说话都不敢高声,也不能出高...

  • 【日精进打卡第356天】

    扬州方圆~~周亮 【知~学习】学习一级建造师内容 《六项精进》3遍。累积1068遍 《大学》3遍。累积1068遍 ...

  • 每日一画:1068,1069

    1068:画绘本字母Q系列~ 1069:模仿漫画~

  • 2019-05-21 P1068

    题目链接:https://www.luogu.org/problemnew/show/P1068

  • 1068 乌龟棋

    题目: 小明过生日的时候,爸爸送给他一副乌龟棋当作礼物。 乌龟棋的棋盘是一行N个格子,每个格子上一个分数(非负整数...

  • POJ1068

    问题描述### 一组括号 (((( ) ( ) ( ) ) ) ) 有两种描述方法: P方法:4 5 6 6 6 ...

  • 1068:中秋快乐

    今天9月22日,中秋。 中秋节必定是要吃月饼的。前几天我自己在家做了月饼,现在就只剩下几个了。但今天早...

网友评论

      本文标题:1068

      本文链接:https://www.haomeiwen.com/subject/dyaujxtx.html