1 条题解

  • 0
    @ 2023-5-4 20:08:23
    #include <iostream>
    using namespace std;
    int main()
    {
        int n,m,a[999][999],d,b;
        bool c=0;
        cin >> n >> m;
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=m;j++)
            {
                cin >> a[i][j];
            }
        }
        cin >> d >> b;
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=m;j++)
            {
                if(a[i][j]==d)
                {
                    if(a[i+1][j]==b || a[i-1][j]==b || a[i][j+1]==b || a[i][j-1]==b)
                    {
                        c=1;
                        break;
                    }
                }
            }
        }
        if(c)
        {
            cout << "Y";
        }
        else
        {
            cout << "N";
        }
    }
    
    • 1

    信息

    ID
    997
    时间
    1000ms
    内存
    64MiB
    难度
    2
    标签
    递交数
    26
    已通过
    23
    上传者