codeforces 989B 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... 阅读详情

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 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

s

s 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

p

p 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

p

p is considered a period of string

s

s , if for all

1 \leq i \leq \lvert s \rvert - p

1≤i≤∣s∣−p , the

i

i -th and

(i + p)

(i+p) -th characters of

s

s are the same. Here

\lvert s \rvert

∣s∣ is the length of

s

s .

输入输出格式
输入格式:

The first line contains two space-separated integers

n

n and

p

p (

1 \leq p \leq n \leq 2000

1≤p≤n≤2000 ) — the length of the given string and the supposed period, respectively.

The second line contains a string

s

s of

n

n characters — Mino’s records.

s

s only contains characters ‘0’, ‘1’ and ‘.’, and contains at least one ‘.’ character.

输出格式:

Output one line — if it’s possible that

p

p 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)).

输入输出样例
输入样例#1: 复制

10 7
1.0.1.0.1.
输出样例#1: 复制

1000100010
输入样例#2: 复制

10 6
1.0.1.1000
输出样例#2: 复制

1001101000
输入样例#3: 复制

10 9
1……..1
输出样例#3: 复制

No
说明
In the first example,

7

7 is not a period of the resulting string because the

1

1 -st and

8

8 -th characters of it are different.

In the second example,

6

6 is not a period of the resulting string because the

4

4 -th and

10

10 -th characters of it are different.

In the third example,

9

9 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.

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,p,flag[2];char s[2200],s1[2200];
int main(){
    freopen("b.in","r",stdin);
    scanf("%d%d",&n,&p);scanf("%s",s+1);
    bool ans=1;
    for (int i=1;i<=n-p;++i){
        flag[0]=flag[1]=0;
        for (int j=i;j<=n;j+=p){
            if (s[j]=='.') flag[0]=flag[1]=1;
            else flag[s[j]-'0']=1;
        }
        if(flag[0]==flag[1]==1) ans=0; 
    }if (ans) {puts("No");return 0;}
    for (int i=1;i<=n-p;++i){
        if(s[i]=='.'&&s[i+p]=='.'){
            s[i]='0';s[i+p]='1';continue;
        }flag[0]=flag[1]=0;bool flag1=0;
        if (s[i]!='.') flag[s[i]-'0']=1;
        if (s[i+p]!='.') flag[s[i+p]-'0']=1;
        if (!flag[0]) flag1=0;else flag1=1;
        if (s[i]=='.') s[i]='0'+flag1;
        if (s[i+p]=='.') s[i+p]='0'+flag1;
    }//printf("%s",s+1);puts("");
    for (int i=1;i<=n;++i) 
    if (s[i]=='.') s[i]='0';
    printf("%s",s+1);
    return 0;
}
雷达截面积建模仿真(RCS) 在目标侧,其形状、材料、尺寸(相对于雷达波长)和相对于雷达观察方向的方向等特征都会影响雷达看到的RCS。严格的数学处理超出了讨论的范围,但入射波和目标之间的相互作用可以定性描述。对于给定的散射方向,可以积分求和物体表面电流的振幅相位,当电流同相时,会出现较大的回波幅度。随着目标方向和雷达视角随时间变化,电流振幅和相位会发生变化,形成看似随机的峰值和零点的散射模式,出现“相长”和“相消”干涉。除了雷达到目标的距离外,雷达截面(RCS)是RRE(雷达距离方程)中唯一与目标相关的参数,因此不在雷达设计者的。 阅读详情

相关推荐

基于STM32的可穿戴式多生理参数实时监测与预警系统

针对传统可穿戴健康设备存在的生理参数监测种类单一、数据处理依赖云端导致响应滞后、续航能力弱等问题,设计一种基于STM32的可穿戴式多生理参数实时监测与预警系统。系统以STM32L476RG低功耗微控制器为核心,集成心率血氧传感器、体温传感器、血压传感器,实现人体心率、血氧饱和度、体温、收缩压/舒张压的同步采集;通过边缘端轻量化数据处理算法完成参数异常判定,结合低功耗硬件设计与软件休眠策略,在保证监测精度的同时延长续航。测试结果表明,系统心率监测误差≤2次/分钟,血氧饱和度误差≤2%,体温误差≤±0.2℃,血

m0_74026776的博客 2049

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

测试dali协议的软件,DALI2.0和DALI1.0完美兼容同一个模块,测试每项可过协议

DALI2.0和DALI1.0完美兼容同一个模块,测试每项可过协议深圳聚积智能 夏先生 13246760327 QQ 349098308■IEC62386-102(V2.0)通过测试内容IEC62386-102/2.1/Test preambleIEC62386-102/3.1/Polarity testIEC62386-102/3.2/Maximum and minimum system v...

weixin_35343788的博客 1352

Codeforces Round #487 (Div. 2)

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

dilei7762的博客 208

Qt Coordinate System

Qt 坐标系统Qt 坐标系统 数学基础 Qt坐标系统 视口 平移变换 缩放变换 setWindow 旋转 总结数学基础 矩阵与线性变换坐标系变换Qt坐标系统 视口和OpenGL一样,视口确定了画面在窗口(QWidget)中显示的区域,Qt的绘图坐标会完全映射到视口(View port)上,就像图示一样。默认情况下,窗口和视口是重合的,视口的大小覆盖了整个窗口。和OpenGL一样,Qt的QPa

unclerunning的博客 1155

基于Python API的ECMWF大气数据批量下载与自动化处理实践

本文详细介绍了如何利用Python API实现ECMWF大气数据的自动化批量下载与处理。针对遥感分析中手动下载ERA5等数据的痛点,文章提供了从API密钥配置、核心脚本编写到元数据解析、任务队列调度及数据质量检查的全流程实践指南,旨在帮助科研与工程人员高效获取并处理大规模气象数据。

u8v9w0x1y的博客 481

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

Latex里面关于作者名字显示有灰色; 二级+三级标题斜体;

Latex里面关于 作者名字显示有灰色; 二级+三级标题斜体,与正文的距离; 邮箱字体;ORCID字体设置(整理不易,请先关注,Thanks)

m0_61015717的博客 750

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

无人机导航中的坐标系统详解与转换实现

本文系统介绍了无人机导航中常用的坐标系及其转换方法。主要内容包括:1) 四种关键坐标系(大地坐标系ECEF、经纬度LLA、北东天坐标系NED、机体坐标系)的定义和特点;2) 坐标系间的转换原理与实现,重点讲解LLA与ECEF的互转公式及ECEF与NED的转换方法;3) 提供可直接使用的C++实现代码,包括基于WGS84椭球模型的精确转换算法。这些内容为无人机导航系统开发提供了实用的坐标系处理方案,能够有效解决多源数据在不同坐标系下的统一表示问题。

电脑管家 383

YOLO11实战优化:长尾分布解决 | 引入Seesaw Loss配合YOLO11分类头,完美应对类别极其不平衡的现实业务场景

摘要: YOLO11在工业缺陷检测等长尾分布场景中面临尾部类别检测失效的问题,根源在于头部类别样本的负样本梯度压制了尾部类别的学习。传统方法如重采样、Focal Loss等效果有限。Seesaw Loss通过动态调整缓解因子和补偿因子,平衡类别间的梯度分布,结合YOLO11的解耦分类头、Anchor-Free设计和C2PSA/C3K2模块,显著提升尾部类别识别能力。文章详细解析了Seesaw Loss的数学原理,并提供了可直接集成到YOLO11的PyTorch实现代码,为长尾分布下的目标检测提供了实用解决方

2601_95807009的博客 259

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

如何分段长tree

可以将clock1 tree上所有的cell don’t touch,update一下sdc,将clock2的信息load进来。那么,此时只要将clock1的定义去除,用delete_ccopt_clock_tree_spec将原先已经load的spec删除,然后再次创建clock tree spec,那么此时工具只会生成clock2的spec。cts之后,工具便会生成只有clock2的clock tree。那么,作为思考题,童鞋们可以试试看如何才能实现在mux I0之前长1ns的clock tree。

芯冰乐 517

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

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

lwip-2.0.3

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

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

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

Codeforces Round #487 (Div. 2) ---- B.A Tide of Riverscape

题目链接:http://codeforces.com/contest/989/problem/B 题意: 给你一个串S由可能由’1’, ‘0’, ‘.’这三种字符组成,其中’.’表示它可能为‘1’或者为‘0’。它让你保证这个串中按照每p为一个周期,只有存在一对s[i]和s[i+p]是不相同的字符。输出满足题意的任意一个答案即可。 反思: 这个题就是需要注意的讨论好细节,被Hack 惨痛掉灰QA...

WangMeow --- ᶘ ᵒᴥᵒᶅ ฅ^•ﻌ•^ฅ 167

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

队内每周训练_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

CF989B A Tide of Riverscape

这题在我的洛谷博客上也有 https://www.luogu.org/blog/kyx0806/ 这题就是一道模拟,要考虑的方面还是挺多的,坑。。也挺多的 附上代码,讲解在代码里 这题因为是输出随意一种所以有很多种做法,我的方法可能比较麻烦因为是错了几遍改了几遍后AC的 【仅供参考】 #include &lt;algorithm&gt; #include &lt;iostream&gt...

jkrj02 360

【codeforces 998B】B. 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...

duanghaha的博客 411

Codeforces Round #487 (Div. 2)补题博客

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...

我是谁 --- 卡比兽 591

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 989B

题意:字符串长度为n,'.'可以变成‘0’或‘1’,问是否存在两个字符不相等。   由于数据范围&lt;2000,所以我用的是暴力枚举的方法,即用for从头遍历,枚举所有可能出现的情况。 代码如下: #include &lt;stdio.h&gt; #include&lt;iostream&gt; #include&lt;algorithm&gt; #include&lt;string&...

zsnowwolfy的博客 262

codeforces 937A Olympiad

http://www.elijahqi.win/2018/02/26/codeforces-937a-olympiad/ The recent All-Berland Olympiad in Informatics featured n participants with each scoring a certain amount of points. As the head of the p...

Elijahqi 2911

codeforces 913B Christmas Spruce

http://www.elijahqi.win/2018/01/09/codeforces-913b-christmas-spruce/ B. Christmas Spruce time limit per test 1 second memory limit per test 256 megabytes input standard input output standard

Elijahqi 1196
上一篇: codeforces 989A A Blend of Springtime
下一篇: codeforces 989C A Mist of Florescence
elijahqi
博客等级 码龄9年 55粉丝 1280原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值