【codeforces 998B】B. A Tide of Riverscape

A Tide of Riverscape CodeForces - 989B (水题) B. A Tide of Riverscapetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputWalking along a riverside, Mino silently takes a note of something."Time," M... 阅读详情

B. A Tide of Riverscape
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Walking along a riverside, Mino silently takes a note of something.

"Time," Mino thinks aloud.

"What?"

"Time and tide wait for no man," explains Mino. "My name, taken from the river, always reminds me of this."

"And what are you recording?"

"You see it, tide. Everything has its own period, and I think I've figured out this one," says Mino with confidence.

Doubtfully, Kanno peeks at Mino's records.

The records are expressed as a string ss of characters '0', '1' and '.', where '0' denotes a low tide, '1' denotes a high tide, and '.' denotes an unknown one (either high or low).

You are to help Mino determine whether it's possible that after replacing each '.' independently with '0' or '1', a given integer pp is not a period of the resulting string. In case the answer is yes, please also show such a replacement to Mino.

In this problem, a positive integer pp is considered a period of string ss, if for all 1≤i≤|s|−p1≤i≤|s|−p, the ii-th and (i+p)(i+p)-th characters of ss are the same. Here |s||s| is the length of ss.

Input

The first line contains two space-separated integers nn and pp (1≤p≤n≤20001≤p≤n≤2000) — the length of the given string and the supposed period, respectively.

The second line contains a string ss of nn characters — Mino's records. ss only contains characters '0', '1' and '.', and contains at least one '.' character.

Output

Output one line — if it's possible that pp is not a period of the resulting string, output any one of such strings; otherwise output "No" (without quotes, you can print letters in any case (upper or lower)).

Examples
input
Copy
10 7
1.0.1.0.1.
output
Copy
1000100010
input
Copy
10 6
1.0.1.1000
output
Copy
1001101000
input
Copy
10 9
1........1
output
Copy
No
Note

In the first example, 77 is not a period of the resulting string because the 11-st and 88-th characters of it are different.

In the second example, 66 is not a period of the resulting string because the 44-th and 1010-th characters of it are different.

In the third example, 99 is always a period because the only constraint that the first and last characters are the same is already satisfied.

Note that there are multiple acceptable answers for the first two examples, you can print any of them.

比赛时因为少判断了一个条件,结果被Hack了,不应该啊。。。

#include<bits/stdc++.h>
using namespace std;
#define MAXN 100050
char c[MAXN];
int main()
{
	int n,t;
	cin>>n>>t;
	for(int i=0;i<n;i++) cin>>c[i];
	int flag=0;
	for(int i=0;i<t;i++)
	{
		for(int j=i+t;j<n;j+=t)
		{
			if(c[i]=='1'&&c[j]=='.')
			{
				flag=1;
				c[j]='0';
			}
			else if(c[i]=='0'&&c[j]=='.')
			{
				flag=1;
				c[j]='1';
			}
			else if(c[i]=='.'&&c[j]=='1')
			{
				flag=1;
				c[i]='0';
			}
			else if(c[i]=='.'&&c[j]=='0')
			{
				flag=1;
				c[i]='1';
			}
			else if(c[i]=='.'&&c[j]=='.')
			{
				flag=1;
				c[i]='0';
				c[j]='1';
			}
			else if(c[i]=='0'&&c[j]=='1')
			{
				flag=1;
			}
			else if(c[i]=='1'&&c[j]=='0')
			{
				flag=1;
			}
		}
	}
	if(flag) 
	{
		for(int i=0;i<n;i++)
		{
			if(c[i]=='.')
			{
				c[i]='1';
			}
		}
		for(int i=0;i<n;i++) cout<<c[i];
		cout<<endl;
	}
	else cout<<"No"<<endl;
	return 0;
}

树莓派通过TTL3.3转485 Modbus采集水表 所需道具 树莓派0,我用的是树莓派zero wh; 具有光电直读功能的有线水表,我用的是咸鱼淘的埃美柯LXSY-20E1; TTL3.3 转 485模块,带隔离的贵些; 5V转12V升压模块。 原理 树莓派有UART(GPIO14 Tx 和 GPIO15 Rx)串口通讯功能,电器特性是3.3V TTL,直读远传水表支持M-Bus/485通讯接口,我买的光电直读水表485要求12V供电(根据仪表厂家说明书)。TTL和485虽然都是串口通讯,但电器特性不一样,不能直接接!我已经烧掉一个树莓派... 阅读详情

相关推荐

【福建dem】原始高程数据tif格式

DEM(Digital Elevation Model,数字高程模型)是一种地理信息系统中的关键数据集,它提供了地表地形的三维信息,通常用于分析地貌特征、模拟水文过程、规划建设、灾害预警等多个领域。这种数据对于地理分析非常有价值,例如,它可以用于计算坡度、坡向、地形粗糙度等地形特征,或者进行洪水模拟、地质灾害评估、太阳能辐射分析等。“福建dem原始高程数据tif格式”是研究和理解福建省地形地貌的重要资源,结合GIS工具,可以揭示丰富的地理信息,为科研、工程和决策提供有力支持。

鸿业远图科技 953

Codeforces998 B. Cutting(思维)

题意: 解法: 将奇数位置看作1,偶数位置看作-1, 设b[]为这些1和-1的前缀和, 如果b[n]!=0,那么无法进行操作. 否则每一个b[i]=0的位置,(i,i+1)都可以切割. 将所有可切割位置的代价存下来,从小到大排序, 优先切割代价小的位置即可. code: #include <bits/stdc++.h> #define int long long using namespace std; const int maxm=2e6+5; int a[maxm]; int b[ma

zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz 210

QGIS实战:5分钟搞定谷歌地图、高德、天地图等多源地图加载(附最新图源URL)

本文详细介绍了如何在QGIS中快速加载谷歌地图、高德、天地图等多源地图,提供2023年验证可用的最新图源URL和配置步骤。从环境准备到高级技巧,涵盖国内外主流地图服务的完整解决方案,帮助用户提升GIS工作效率。

weixin_29210759的博客 1258

B. A Tide of Riverscape

      B. A Tide of Riverscape time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Walking along a riverside, Mino silently takes a ...

这里RevolIA,_(:з」∠)_ 351

【论文复现】自动化细胞核分割与特征分析

HoVer-Net是一种精心设计的多分支深度学习网络架构,专为处理复杂的多组织显微图像中的细胞核实例分割与精确分类任务而开发。该网络通过创新的策略,不仅有效解决了细胞核在密集聚集区域难以准确区分的问题,还实现了对每个独立细胞核类型的细致分类。此外,HoVer-Net还引入了专门的上采样分支,这一设计旨在对每个成功分割出的细胞核实例进行进一步的核类型分类。这一分支利用高级语义信息,结合精心设计的分类策略,能够准确判断每个细胞核的所属类型,为医学研究提供了宝贵的细胞水平信息。

2201_75366661的博客 1982

模型预测控制(MPC)解析(二):单输入单输出系统

在上一篇中,为了便于说明,预测控制系统采用单输入单输出系统为例进行设计。由于系统模型使用的是状态空间方程,于是可以很容易的将这种设计方法可以扩展到多输入、多输出系统。

行者无疆的博客 8229

Codeforces Round #487 (Div. 2)

比赛链接 http://codeforces.com/contest/989 吐槽? 公告写的好,故事写的好啊。 两题滚粗,凭借着手速与hack +1:-1成功涨了一波rating……还是我太菜了。 下面只有ABC三题题解,想找DE题解的dalao可以换一篇了,为了保持良好的阅读体验,代码都放在最后面。 A. A Ble...

dilei7762的博客 208

PhotovoltaicPanelCleanlinessDetector:基于YOLOv8的光伏板清洁状态监测系统

data.yamlyaml复制编辑names:0: clean1: dust3: leaves4: shadow✅ 高精度污染识别✅ 具备实时检测与UI展示✅ 可本地化部署应用未来方向增加污染程度分级(轻度、中度、严重)加入时间序列分析(污染变化趋势预测)无人机集成巡检模块。

YOLO 278

CodeForces ~ 998B ~ Cutting (贪心)

题意给你n个数字,保证奇数个数和偶数个数相等。你可以把该序列分割成(连续的)片段,使得每一段的奇数和偶数个数相等,假设在x和y元素中间分割,那么花费|x-y|块钱。你有k块钱,最多可以分割多少次?题解从开头统计奇数和偶数的个数,如果某个位置奇数和偶数个数相等就把当前这个花费放入set中,然后贪心的选择最小的即可。#include &lt;bits/stdc++.h&gt; using namesp...

张松超的博客 568

【云原生】Docker可视化工具Portainer使用详解

Docker可视化工具Portainer使用详解

congge 1万+

TIA protal与SCL从入门到精通(1)——SCL编程入门

SCL语言是由Pascal而生的结构化程序语言,与梯形图相(LAD)比,SCL语言的灵活程度更高,易于编写控制算法。 本教程基于的平台如下 软件:TIA 15.1 CPU 1516 (1)直接创建纯SCL的程序块儿; (2)在LAD/FBD中在插入SCL程序段。 在程序段中直接右击插入即可,但是插入的程序段并不能完全使用SCL语法,GOTO等跳转指令就不能使用。在SCL中一般不能使用绝对地址进...

苦走一口田 7万+

989B A Tide of Riverscape

B. A Tide of Riverscapetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputWalking along a riverside, Mino silently takes a note of something."Time," M...

memory_qianxiao的博客 1062

上位机 寻边器 通讯实战

寻边器通讯接口实现 本文介绍了上位机与盖泽(Gazer)和JEL品牌寻边器的通讯接口实现方案。主要内容包括: 接口定义:创建了IAlignerOperation接口,定义了获取状态、控制运动、真空吸附等核心功能。 具体实现: 盖泽寻边器(GazerAlignerCjh):通过串口通讯,实现了回零、校准、移动位置等操作 JEL寻边器(JelAligner):同样基于串口通讯,包含错误处理、状态查询等功能 工厂模式:通过AlignerFactory工厂类根据设备品牌创建对应的实现对象。 设备加载:展示了如何在系

StevenChen的博客 384

A Tide of Riverscape CodeForces - 989B(水题)

A. A Blend of Springtimetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputWhen the curtains are opened, a canvas unfolds outside. Kanno marvels at al...

JiaYao的博客 498

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

队内每周训练_1(补题)

Hit the LotteryIf at first you don't succeed...A Tide of RiverscapeBus Video SystemCut 'em all!Covered Points Count Hit the Lottery Allen has a LOT of money. He has n dollars in the bank. For security reasons, he wants to withdraw it in cash (we will not .

m0_51864047的博客 389

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

Balloons CodeForces - 998A (水题)

A. Balloonstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are quite a lot of ways to have fun with inflatable balloons. For example, you can...

JiaYao的博客 785

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

CodeForces ~ 998A ~ Balloons (水)

题意 n个数字分给两个人,使得A得到的数字和大与B得到的数字和,输出A的得到的数字的下标(任意解且顺序随意),如果无解输出-1。 思路 直接把最小的给B,其他的全给A。 #include &lt;bits/stdc++.h&gt; using namespace std; const int MAXN = 505; const int INF = 0x3f3f3f3f; int n, ...

张松超的博客 494

Codeforces998:ABCD-Round#493

(有任何问题欢迎留言或私聊 &amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp; 欢迎交流讨论哦 题目链接:传送门 (题面在最下面) A. Balloons  A题的意思是把一个序列分成两部分,然后要求两部分的和不一样。  每部分必须有至少一个数。  当有解时,肯定有一种情况时这个人只选择一个数字,直接写就好了。  (第一发用了sort,果然wa了一发,还好wa了,不然就sb了) AC代码: #incl...

打过ICPC/CCPC,学习ACM算法,Linux内核,Openharmony,加油努力开心珍惜 516

Cutting CodeForces - 998B (思维)

B. Cuttingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are a lot of things which could be cut — trees, paper, "the rope". In this problem...

JiaYao的博客 761

Codeforces 989B A Tide of Riverscape

The records are expressed as a stringssof characters '0', '1' and '.', where '0' denotes a low tide, '1' denotes a high tide, and '.' denotes an unknown one (either high or low). You are to help...

本该如此 372

codeforces 989B A Tide of Riverscape

http://www.elijahqi.win/archives/3660 题目描述 Walking along a riverside, Mino silently takes a note of something.”Time,” Mino thinks aloud. “What?” “Time and tide wait for no man,” explains Mino. “My...

Elijahqi 448

Codeforces Round #493 (Div. 2) A. Balloons

A. Balloonstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are quite a lot of ways to have fun with inflatable balloons. For example, you can...

c8241998的博客 318

CodeForces ~ 989B ~ A Tide of Riverscape (模拟)

题意: 给定一个初始包含 .01 的字符串, . 可以变成 0 或 1 ,问有没有一种方案使得这个字符串周期不为 p ,如果有随意输出一种,如果没输出NO。 解法: 写的时候自信锁一波,结果锁完就后悔。其实我们只需要使得某一个a[i]!=a[i+p]a[i]!=a[i+p]a[i] != a[i+p] 即可,然后其他位置随便填 #include &lt;bits/stdc++.h&gt; us...

张松超的博客 453

Codeforces-989B - A Tide of Riverscape - 思维

题解链接 http://www.lucien.ink/archives/269/ 题目链接 http://codeforces.com/contest/989/problem/B 题目 The records are expressed as a string s of characters ‘0’, ‘1’ and ‘.’, where ‘0’ denotes a low ti...

LucienShui 676

CF989B A Tide of Riverscape 思维 第七题

A Tide of Riverscape time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Walking along a riverside, Mino sil...

weixin_34266504的博客 180

CodeForces - 998D - Roman Digits(打表 找规律)(本来应该是推公式的题吧)

题目链接: http://codeforces.com/problemset/problem/998/D 题目: Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers 1, 5, 10 and 5...

QDU_ZXF的博客 3304
上一篇: 【HDU 2087】剪花布条(KMP)
下一篇: 【HDU 1051】Wooden Sticks(最长上升子序列)
codancer
博客等级 码龄9年 120粉丝 208原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值