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

啊啊啊啊啊啊,简直了,佩服我自己,一个等于符号写成赋值符号,调半天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 思维 第七题的更多相关文章

  1. 《学习OpenCV》练习题第四章第七题abc

    题外话:一直是打算把这本书的全部课后编程题写完的,中间断了几个月,一直忙于其他事.现在开始补上. 这道题我不清楚我理解的题意是不是正确的,这道题可以练习用OpenCV实现透视变换(可以用于矫正在3维环 ...

  2. 经典算法题每日演练——第七题 KMP算法

    原文:经典算法题每日演练--第七题 KMP算法 在大学的时候,应该在数据结构里面都看过kmp算法吧,不知道有多少老师对该算法是一笔带过的,至少我们以前是的, 确实kmp算法还是有点饶人的,如果说红黑树 ...

  3. python在leecode刷题-第一题和第七题

    class Solution(object): def twoSum(self, nums, target): """ :type nums: List[int] num ...

  4. 思维|蚂蚁感冒|2014年蓝桥杯A组题解析第七题-fishers

    标题:蚂蚁感冒 长100厘米的细长直杆子上有n只蚂蚁.它们的头有的朝左,有的朝右. 每只蚂蚁都只能沿着杆子向前爬,速度是1厘米/秒. 当两只蚂蚁碰面时,它们会同时掉头往相反的方向爬行. 这些蚂蚁中,有 ...

  5. CTF---Web入门第七题 猫抓老鼠

    猫抓老鼠分值:10 来源: 实验吧 难度:难 参与人数:8697人 Get Flag:3740人 答题人数:3944人 解题通过率:95% catch!catch!catch!嘿嘿,不多说了,再说剧透 ...

  6. CTF---密码学入门第七题 杯酒人生

    杯酒人生分值:10 来源: Veneno 难度:易 参与人数:2633人 Get Flag:790人 答题人数:963人 解题通过率:82% 使用古典密码 一喵星人要想喵星发送一段不知道干什么用的密码 ...

  7. LLLYYY的数字思维(模拟题)

    链接:https://ac.nowcoder.com/acm/contest/318/G LLLYYY很喜欢写暴力模拟贪心思维.某一天在机房,他突然抛给了队友ppq一 个问题.问题如下: 有一个函数f ...

  8. 第一章-第七题( 有人认为,“中文编程”, 是解决中国程序员编程效率一个秘密武器,请问它是一个 “银弹” 么? )--By 侯伟婷

    首先,“银弹”在百度百科中的解释是银色的子弹,我们更熟知的“银弹”一词,应该是在<人月神话>中提到的.银弹原本应该是指某种策略.技术或者技巧可以极大地提高程序员的生产力[1].此题目中关于 ...

  9. leetcode第七题Reverse Integer (java)

    Reverse Integer Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, retu ...

随机推荐

  1. PID算法资料【视频+PDF介绍】

    最近一直有网友看到我的博客后,加我好友,问我能不能给发一些PID的资料,今天找了一些资料放到百度网盘上,给大家下载: 视频资料 链接:https://pan.baidu.com/s/12_IlLgBI ...

  2. sql server 2008 外键的级联操作

    问题提出:现在我有三张表,学生Student,课程Course,成绩SC 1.  学生表Student,主键是学号Sno 2.  课程Course,主码是课程号Cno 3.  成绩SC,主码是Sno和 ...

  3. Mac 10.14.4 编译openjdk1.9源码 及集成clion动态调试

    警告⚠️:本文耗时很长,先做好心理准备:编译openjdk源码需要很大的耐心,因为要踩很多坑,解决很多问题,本人从编译开始到结束用了两天时间,按照本篇教程踩坑会少许:谢谢观看 一.获取openjdk源 ...

  4. Android 虹软人脸识别SDK-人脸对比

    准备 : 登录官方网站,获取SDK,进行个人验证后新建项目,获取APP_ID,和SDK_KEY: https://ai.arcsoft.com.cn/ucenter/resource/build/in ...

  5. 佳木斯集训Day7

    毒瘤出题人!!! T2的题面和样例不一样,所以我挂了(没错这就是我写模拟写挂了的理由) T1 大水题,懒得解释了,五分钟AC #include <bits/stdc++.h> #defin ...

  6. No!No!No! It's not fashion!

    还记得搞怪的hold住姐Miss Lin么,对于人们常规的行为,Miss Lin会挑起夸张的眉毛说:"Oh my God, it's not fashion!".如果程序员圈子里有 ...

  7. LeetCode——264. Ugly Number II

    题目: Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime fact ...

  8. 【0801 | Day 6】Python基础(四)

    Part 13 流程控制之while循环 一.语法 while 条件 code 1 code 2 code 3 ... ​ while True: print('*1'*100) print('*2' ...

  9. shell 提取文件名和目录名

    转自http://blog.csdn.net/universe_hao/article/details/52640321 shell 提取文件名和目录名 在写shell脚本中,经常会有需要对路径和文件 ...

  10. temperatureConversion1

    (原题:https://www.python123.io/student/courses/934/groups/8102/problems/programmings/6078) Solution: # ...