蒟蒻0分求助
查看原帖
蒟蒻0分求助
1413352
iilong楼主2025/7/30 10:43
#include <iostream>
using namespace std;

char a[101][101];
char yang[4][4] = {
    '0','0','0','0',
    '0','1','1','0',
    '0','1','1','0',
    '0','0','0','0'
};

bool check(int x1, int y1, int x2, int y2)
{
	for(int i = x1;i <= x2;i++)
	{
		for(int j = y1;j <= y2;j++)
		{
			int tx = i - x1;
			int ty = j - y1;
			if(a[i][j] != yang[tx][ty])
			{
				return false;
			}
		}
	}
	return true;
}

int main()
{
	int t;
	cin >> t;
	while(t--)
	{
		int n,m;
		cin >> n >> m;
		for(int i = 1;i <= n;i++)
		{
			for(int j = 1;j <= m;j++)
			{
				cin >> a[i][j];
			}
		}
		for(int x1 = 1;x1 <= n-3;x1++)
		{
			for(int y1 = 1;y1 <= m-3;y1++)
			{
				for(int x2 = x1+3;x2 <= n;x2++)
				{
					for(int y2 = y1+3;y2 <= m;y2++)
					{
						if(check(x1,y1,x2,y2))
						{
							cout << "Yes" << endl;
							return 0;
						}
					}
				}
			}
		}
		cout << "No" << endl;
	}
}
2025/7/30 10:43
加载中...