Codeforces Round #632 (Div. 2)A. Little Artem------题解

在这里插入图片描述
题目大意
构造一个序列满足B=W+1其中B代表的是周围有至少一个′W′的′B′'的总数量,W与之相反。

解题思路
贪心

只需左上角的格子为W,其他都为B即可
这样至少有一个黑色方格相邻的白色单元格的数量只有一个,而与它相邻的黑色方格数目有两个,刚好满足B=W+1

#include <iostream>
using namespace std;
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++) 
			{
				if (i == 1 && j == 1)
					cout << "W";
				else
					cout << "B";
			}
			cout << endl;
		}
	}
	return 0;
}


码字不易,留个赞吧~

发布了50 篇原创文章 · 获赞 63 · 访问量 6218

猜你喜欢

转载自blog.csdn.net/SDAU_LGX/article/details/105417062