DZY Loves Chessboard

Go语言集成Ollama本地大模型:gollama库实战指南 在当今的AI应用开发中,大型语言模型(LLM)的集成已成为关键技术。其核心原理是通过API调用,将自然语言处理能力嵌入到各类应用中。从技术价值看,本地化部署的LLM解决了数据隐私、网络延迟和持续成本三大痛点,尤其适合处理敏感数据或对实时性要求高的场景。在工程实践中,开发者常使用专门的客户端库来简化与模型服务的交互,例如通过封装REST API、提供类型安全接口和流式处理支持,从而提升开发效率和代码健壮性。具体到Go语言生态,结合Ollama这一流行的本地大模型运行工具,可以实现完全离线、低延迟的AI功能集成 阅读详情


DZY loves chessboard, and he enjoys playing with it.

He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a chessman on it. Each chessman is either white or black. After putting all chessmen, DZY wants that no two chessmen with the same color are on two adjacent cells. Two cells are adjacent if and only if they share a common edge.

You task is to find any suitable placement of chessmen on the given chessboard.

Input

The first line contains two space-separated integers n and m (1 ≤ n, m ≤ 100).

Each of the next n lines contains a string of m characters: the j-th character of the i-th string is either "." or "-". A "." means that the corresponding cell (in the i-th row and the j-th column) is good, while a "-" means it is bad.

Output

Output must contain n lines, each line must contain a string of m characters. The j-th character of the i-th string should be either "W", "B" or "-". Character "W" means the chessman on the cell is white, "B" means it is black, "-" means the cell is a bad cell.

If multiple answers exist, print any of them. It is guaranteed that at least one answer exists.

Sample test(s)
input
1 1
.
output
B
input
2 2
..
..
output
BW
WB
input
3 3
.-.
---
--.
output
B-B
---
--B
Note

In the first sample, DZY puts a single black chessman. Of course putting a white one is also OK.

In the second sample, all 4 cells are good. No two same chessmen share an edge in the sample output.

In the third sample, no good cells are adjacent. So you can just put 3 chessmen, no matter what their colors are.

一个棋盘,给你两个颜色,在规定区域涂色,相邻格子不可以同色。一开始用贪心,找到地方就涂B,周围可以涂的都是W,但是这会有bug,比如

.--.

....这样就会出错。所以还是应该用搜索,一直到没有联通的为止。

#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
char c[102][102];
int leap[102][102], m, n;
void bfs(int x, int y,int step)
{
	if (x + 1 <= n&&!leap[x + 1][y] && c[x + 1][y] == '.')
	{
		if (step % 2 == 0)
			c[x + 1][y] = 'W';
		else
			c[x + 1][y] = 'B';
		leap[x + 1][y] = 1;
		bfs(x + 1, y, step + 1);
	}
	if (x - 1 >= 1 && !leap[x - 1][y] && c[x - 1][y] == '.')
	{
		if (step % 2 == 0)
			c[x - 1][y] = 'W';
		else
			c[x - 1][y] = 'B';
		leap[x - 1][y] = 1;
		bfs(x - 1, y, step + 1);
	}
	if (y + 1 <= m&&!leap[x][y + 1] && c[x][y + 1] == '.')
	{
		if (step % 2 == 0)
			c[x][y + 1] = 'W';
		else
			c[x][y + 1] = 'B';
		leap[x][y + 1] = 1;
		bfs(x, y + 1, step + 1);
	}
	if (y - 1 >= 1 && !leap[x][y - 1] && c[x][y - 1] == '.')
	{
		if (step % 2 == 0)
			c[x][y - 1] = 'W';
		else
			c[x][y - 1] = 'B';
		leap[x][y - 1] = 1;
		bfs(x, y - 1, step + 1);
	}
}
int main()
{
	int i, j, ans;
	char s;
	cin >> n >> m;
	memset(leap, 0, sizeof(leap));
	for (i = 1; i <= n;i++)
	for (j = 1; j <= m; j++)
	{
		cin >> c[i][j];
		if (c[i][j] == '-')
			leap[i][j] = 1;
	}
	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= m; j++)
		{
			if (c[i][j]=='.')
			{
				c[i][j] = 'B'; leap[i][j] = 1;
				bfs(i, j,2);
			}
		}
	}
	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= m; j++)
			cout << c[i][j];
		cout << endl;
	}
	return 0;
}

uni-app - 最详细 H5 网页接入微信登录功能,提供公众号配置与详细注释示例代码(移动端网页实现点击登录按钮后 调用微信公众号授权登录功能 详细讲解接入流程与详细示例代码)官方最新超级详细教程 uniapp中H5微信登录,uniapp H5微信授权登录,微信公众号第三方网页(H5)授权登录(OAuth2.0)流程及逻辑详细教程,UNIAPP 开发H5 怎么实现微信公众号登录功能,uniapp如何实现H5网页的公众号微信登录,怎么做uniapp微信登录,uniapp h5项目怎么实现微信登录的功能,uniapp微信浏览器H5授权微信登录,UniApp开发H5接入微信登录的全过程,uniapp的H5页面使用微信登录,uniapp H5微信授权登录,H5之微信授权登陆 (uniapp网页版微信授权登录) 阅读详情

相关推荐

别光看手册!手把手教你用SGM2036 LDO设计一个稳定3.3V转1.8V的MCU供电电路(附PCB布局避坑指南)

本文详细介绍了如何使用SGM2036 LDO设计一个稳定的3.3V转1.8V的MCU供电电路,包括需求分析、芯片选型、外围器件计算、PCB布局避坑指南及实测验证。通过实际案例和计算示例,帮助工程师快速掌握LDO应用技巧,确保系统电源稳定可靠。

weixin_42548893的博客 505

codeforces 985A Chess Placing

A. Chess Placingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a chessboard of size 1 × n. It is guaranteed that n is even. The ches...

七九河开的博客 414

【多媒体交互】Unity+普通摄像头实现UI事件分析

利用摄像头捕捉用户的手势或动作,结合坐标映射与事件系统触发UI交互

qq_38350004的博客 1314

A. DZY Loves Chessboard (CF)

#include using namespace std; #define M 1000 char mat[M][M]; int vis[M][M],v[M][M]; void F(int x,int y,char a) { vis[x][y]=1; if(a=='B') mat[x][y]='W'; else

Ⅶ的专栏 613

调用IP核、移植/复制IP核以及解决IP核被锁住/红锁问题(基于vivado)

解决不同工程IP核之间复制调用以及IP核红锁问题,让开发更简单!

weixin_44502554的博客 1万+

2022李宏毅作业hw1—新冠阳性人员数量预测。

从非常基础的内容开始,主要是我的水平也很基础。

YI_SHU_JIA的博客 1万+

985A Chess Placing

A. Chess Placingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a chessboard of size 1 × n. It is guaranteed that n is even. The ches...

memory_qianxiao的博客 601

多尺度变换(Multidimensional Scaling ,MDS)详解

介绍多尺度变换基本原理

5213

A. DZY Loves Chessboard

解题说明:此题就要求相邻的字母不一样,模拟题,只需要查找时

无知的我 1260

手把手拆解DGX GB200 NVL72:1个机柜如何塞进72块GPU?详解NVLink Switch铜缆背板设计

本文深度解析英伟达DGX GB200 NVL72系统如何通过NVLink Switch铜缆背板设计,在标准42U机柜中集成72块B200 GPU,实现1800GB/s的超高带宽。文章详细介绍了模块化架构、铜缆互连技术、液冷散热方案和高密度供电系统等核心创新,为AI算力需求提供突破性解决方案。

red88的博客 1572

RS485接口EMC设计:三级防护与滤波隔离方案

RS485总线在工业现场面临共模噪声、差模脉冲和地电位差三大电磁兼容挑战。通过三级防护架构(气体放电管、PTC热敏电阻、半导体放电管)实现能量梯次泄放,结合共模扼流圈和滤波电容形成完整防护链。该方案经实测可将6kV浪涌下的通信稳定性提升90%,特别适用于工业自动化、电力监控等严苛环境。设计要点包括防护器件选型计算、PCB分区布局及地处理策略,其中GDT通流能力与TSS箝位电压的配合是关键。

weixin_33419305的博客 521

DZY Loves Chessboard题解

这里附上题目链接:DZY Loves Chessboard。 题目 描述 一个棋盘上有一些格子是坏的,另一些是正常的。对于每一个正常的格子,都要在上面放上棋子。 请找到一组解使没有两个相同颜色的棋子相邻(两个格子相邻为它们存在共同的边) 输入格式 第一行为两个数n,m。(1<=n,m<=100) 下面n行,每个格子上的字符为’-‘或’.’,’-‘表示坏掉的格子,’.'表示正常的格子。 ...

ZhuhaoNan134的博客 633

LangGraph实战训练营-从零构建AI驱动的wiki知识库

本文深入解析 LangChain 团队开源的 Deep Agents 框架核心示例——LLM Wiki,一个基于大语言模型自动构建和维护持久化知识库的生产级 AI Agent 系统。文章从项目架构、环境搭建、核心原理到实战操作全面展开:详解 CompositeBackend 组合后端与细粒度权限控制的安全设计、四种工作模式(初始化/摄取/查询/质量检查)的完整流程、LangSmith 远程沙箱的隔离执行机制,以及人机协同审核(HITL)的实践应用。

program哲学 197

CF445A DZY Loves Chessboard 题解

CF445A DZY Loves Chessboard 题解

yaosichengalpha的博客 1428

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

CodeForces445A DZY Loves Chessboard

A. DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY loves chessboard, and he enjoys playing ...

weixin_33937778的博客 2万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

dzy loves chessboard

Description DZY loves chessboard, and he enjoys playing with it. He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY want

zienyang的专栏 619

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

DZY Loves Chessboard(杂)

A. DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY loves chessboard, and he enjoys playing...

Simone chou... 251

CF 445A DZY Loves Chessboard

A. DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY loves chessboard, and he enjoys playing ...

weixin_33907511的博客 141

【CodeForces】445A - DZY Loves Chessboard(dfs)

题目链接:点击打开链接 A. DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY loves chessboar

wyg1997 876

【CF】DZY Loves Chessboard

传送门:戳我

Lorry酱的专栏 500

【Codeforces 445A DZY Loves Chessboard 】+ 思维

A. DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input standard input output standard outputDZY loves chessboard, and he enjoys playing with it.He has a

楚江枫 487

codeforces 445 A. DZY Loves Chessboard

A. DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY loves chessboard, and he enjoys

R 324

DZY Loves Chessboard (周赛2)

DZY loves chessboard, and he enjoys playing with it. He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a ches

ZHC_AC的博客 493
上一篇: Flipping Game
下一篇: Dreamoon and WiFi
Techay
博客等级 码龄11年 11粉丝 174原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值