CF989B A Tide of Riverscape 思维 第七题
1 second
256 megabytes
standard input
standard output
"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 ssare the same. Here |s||s| is the length of ss.
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 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)).
10 7
1.0.1.0.1.
1000100010
10 6
1.0.1.1000
1001101000
10 9
1........1
No
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.
啊啊啊啊啊啊,简直了,佩服我自己,一个等于符号写成赋值符号,调半天bug
题意:给你n个字符串,问你每隔k个是否右不相等的,没有输出"No",有输出一个符合不相等的(注意‘.'可以是0或者1,所以输出的时候'.'是会根据前后的数字发生变化的)
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(a) cout << #a << " " << a << endl
using namespace std;
const int maxn = 1e6 + ;
const int mod = 1e9 + ;
typedef long long ll;
int main(){
std::ios::sync_with_stdio(false);
ll n, k;
while( cin >> n >> k ) {
string s;
cin >> s;
ll num;
bool flag = false;
for( ll i = ; i < s.length(); i ++ ) {
if( i + k < s.length() ) {
if( s[i] != s[i+k] || ( s[i] == s[i+k] && s[i] == '.' ) ) {
if( s[i] == s[i+k] ) {
s[i] = '', s[i+k] = '';
} else {
if( s[i] == '' ) {
s[i+k] = '';
} else if( s[i] == '' ) {
s[i+k] = '';
} else {
if( s[i+k] == '' ) { //这里等于号写成了赋值符号,调了半天bug,吐血ing
s[i] = '';
} else {
s[i] = '';
}
}
}
flag = true;
break;
}
}
}
if( flag ) {
for( ll i = ; i < s.length(); i ++ ) {
if( s[i] == '.' ) {
cout << "";
} else {
cout << s[i];
}
}
} else {
cout << "No";
}
cout << endl;
}
return ;
}
CF989B A Tide of Riverscape 思维 第七题的更多相关文章
- 《学习OpenCV》练习题第四章第七题abc
题外话:一直是打算把这本书的全部课后编程题写完的,中间断了几个月,一直忙于其他事.现在开始补上. 这道题我不清楚我理解的题意是不是正确的,这道题可以练习用OpenCV实现透视变换(可以用于矫正在3维环 ...
- 经典算法题每日演练——第七题 KMP算法
原文:经典算法题每日演练--第七题 KMP算法 在大学的时候,应该在数据结构里面都看过kmp算法吧,不知道有多少老师对该算法是一笔带过的,至少我们以前是的, 确实kmp算法还是有点饶人的,如果说红黑树 ...
- python在leecode刷题-第一题和第七题
class Solution(object): def twoSum(self, nums, target): """ :type nums: List[int] num ...
- 思维|蚂蚁感冒|2014年蓝桥杯A组题解析第七题-fishers
标题:蚂蚁感冒 长100厘米的细长直杆子上有n只蚂蚁.它们的头有的朝左,有的朝右. 每只蚂蚁都只能沿着杆子向前爬,速度是1厘米/秒. 当两只蚂蚁碰面时,它们会同时掉头往相反的方向爬行. 这些蚂蚁中,有 ...
- CTF---Web入门第七题 猫抓老鼠
猫抓老鼠分值:10 来源: 实验吧 难度:难 参与人数:8697人 Get Flag:3740人 答题人数:3944人 解题通过率:95% catch!catch!catch!嘿嘿,不多说了,再说剧透 ...
- CTF---密码学入门第七题 杯酒人生
杯酒人生分值:10 来源: Veneno 难度:易 参与人数:2633人 Get Flag:790人 答题人数:963人 解题通过率:82% 使用古典密码 一喵星人要想喵星发送一段不知道干什么用的密码 ...
- LLLYYY的数字思维(模拟题)
链接:https://ac.nowcoder.com/acm/contest/318/G LLLYYY很喜欢写暴力模拟贪心思维.某一天在机房,他突然抛给了队友ppq一 个问题.问题如下: 有一个函数f ...
- 第一章-第七题( 有人认为,“中文编程”, 是解决中国程序员编程效率一个秘密武器,请问它是一个 “银弹” 么? )--By 侯伟婷
首先,“银弹”在百度百科中的解释是银色的子弹,我们更熟知的“银弹”一词,应该是在<人月神话>中提到的.银弹原本应该是指某种策略.技术或者技巧可以极大地提高程序员的生产力[1].此题目中关于 ...
- leetcode第七题Reverse Integer (java)
Reverse Integer Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, retu ...
随机推荐
- Java NIO学习系列七:Path、Files、AsynchronousFileChannel
相对于标准Java IO中通过File来指向文件和目录,Java NIO中提供了更丰富的类来支持对文件和目录的操作,不仅仅支持更多操作,还支持诸如异步读写等特性,本文我们就来学习一些Java NIO提 ...
- LASSO原作者的论文,来读读看
Regression Shrinkage and Selection via the lasso 众所周知,Robert Tibshirani是统计领域的大佬,这篇文章在1996年提出了LASSO,之 ...
- macOS 安装配置yaf框架 生成yaf项目
macOS 安装配置yaf框架 Yaf只支持PHP5.2及以上的版本. 并支持最新的PHP5.3.3 Yaf需要SPL的支持. SPL在PHP5中是默认启用的扩展模块 Yaf需要PCRE的支持. PC ...
- Drawable与 Bitmap 转换总结
极力推荐文章:欢迎收藏 Android 干货分享 阅读五分钟,每日十点,和您一起终身学习,这里是程序员Android Drawable 使用方法详解请看上篇文章. Drawable 使用方法详解 本篇 ...
- 简洁明了的Noip考场策略 / 平时做题也适用
1.选择策略: 评估的标准得分的难度不是AC的难度 2.思考问题: 怀疑的眼光审视自己 3.写代码前: 想想可不可以换一种代码实现会好写很多 把自己的思路再理一遍,可以写到纸上,记下来大致关键顺序 4 ...
- RocketMQ中Broker的HA策略源码分析
Broker的HA策略分为两部分①同步元数据②同步消息数据 同步元数据 在Slave启动时,会启动一个定时任务用来从master同步元数据 if (role == BrokerRole.SLAVE) ...
- idea中的springboot项目如何不用重新编译,自动热部署
两步走:引入依赖,配置idea 在pom.xml中引入如下依赖,关键字:devtools 第二步,修改idea两处配置 2.1 windows下,ctl+alt+s打开idea配置菜单 左上角输入框搜 ...
- 为什么我们不用JIRA
很多人问我,缺陷管理工具,为什么不用jira?而去自己造轮子开发一款bug记录系统 缄默如我,原因众多.如果只是3-5分钟就能讲的请的时候,我会先列出什么糟点呢? 1. 收费,一个人一个月的费用差不多 ...
- stm8s和stm8l低功耗对比
在低功耗应用中,一般来说mcu是常态halt模式,然后偶尔被唤醒(外部中断或者内部定时唤醒)进入运行模式.所以对比低功耗性能,一般来说只需要对比run模式和halt下的功耗即可,因为项目选用的是通过内 ...
- js五子棋游戏代码分享
HTML代码 <canvas id="game"></canvas> CSS代码 * { margin: 0; padding: 0; } #game { ...