题意:

一个01串是否合法满足以下两个要求:

1.没有两个相邻的1;

2.在满足第一个条件的情况下,不能再放下更多的1。

判断一个给定的串是否合法。

思路:

最近cf的A怎么都这么坑啊。。。

首先是判断长度为1的情况,为0是No,1就是Yes;

然后判断长度大于1的,有2种一般情况,11,000

2种特殊情况,开头两个0,结尾两个0。

代码:

 #include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int main()
{
int n;
char s[];
scanf("%d%s",&n,s);
bool f = ;
if (n == && s[] == '')
{
f = ;
}
for (int i = ;i < n-;i++) if(s[i] == '' && s[i+] == '') f = ;
for (int i = ;i <= n-;i++)
{
if (i == )
{
if (s[i] == '' && s[i+] == '') f = ;
}
else if (i == n - )
{
if (s[i] == '' && s[i+] == '') f = ;
}
else
{
if (s[i] == '' && s[i+] == '' && s[i+] == '') f = ;
}
}
if (f) puts("No");
else puts("Yes");
return ;
}

codeforces 982A Row的更多相关文章

  1. Educational Codeforces Round 6 C. Pearls in a Row

    Educational Codeforces Round 6 C. Pearls in a Row 题意:一个3e5范围的序列:要你分成最多数量的子序列,其中子序列必须是只有两个数相同, 其余的数只能 ...

  2. codeforces A. Difference Row

    link:http://codeforces.com/contest/347/problem/A 开始看起来很复杂的样子,但是刚写下样例,就发现因为中间的都消去了,其实起作用的就是最大值和最小值=_= ...

  3. codeforces A. Difference Row 解题报告

    题目链接:http://codeforces.com/problemset/problem/347/A 题目意思:给出一个序列 a1, a2, ..., an , 通过重排序列,假设变成 x1, x2 ...

  4. CodeForces - 620C Pearls in a Row 贪心 STL

    C. Pearls in a Row time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  5. Pearls in a Row CodeForces 620C 水题

    题目:http://codeforces.com/problemset/problem/620/C 文章末有一些测试数据仅供参考 题目大意 给你一个数字串,然后将分成几个部分,要求每个部分中必须有一对 ...

  6. Codeforces 620C EDU C.Pearls in a Row ( set + greed )

    C. Pearls in a Row There are n pearls in a row. Let's enumerate them with integers from 1 to n from ...

  7. codeforces C. Pearls in a Row map的应用

    C. Pearls in a Row time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  8. codeforces B. Trees in a Row 解题报告

    题目链接:http://codeforces.com/problemset/problem/402/B 题目意思:给出n个数和公差k,问如何调整使得ai + 1 - ai = k.(1 ≤ i < ...

  9. Educational Codeforces Round 6 C. Pearls in a Row set

    C. Pearls in a Row There are n pearls in a row. Let's enumerate them with integers from 1 to n from ...

随机推荐

  1. python中的if __name__ == 'main'

    当你打开一个.py文件时,经常会在代码的最下面看到if __name__ == '__main__':,现在就来介 绍一下它的作用: 对于编程语言来说,程序都必须要有一个入口,比如java和c#必须要 ...

  2. 如何在 Fiddler Script 中 自定义 修改 Request 、 Response

    Fiddler是一个http协议调试代理工具,方便进行http请求的拦截处理.改写请求.返回值等. 在Rules菜单下:  此次更改请求 头 ,so go to OnBeforeRequest 或者 ...

  3. VS2017 配置glfw3

    直接下载源码使用VS进行编译. 1. 源码下载地址http://www.glfw.org/download.html, 点击Source Package 2. 打开cmake-3.12.1-win32 ...

  4. [原]Jenkins(二十) jenkins再出发之Error: Opening Robot Framework log failed

    错误缘由:使用plugin [public robot framework test results] 生成的HTML文件都无法正常打开.   解决方案: Connect on your jenkin ...

  5. 关于linux下ntp时间同步服务的安装与配置

    1.安装ntp服务,要使用时间同步.那么服务端与客户端都需要使用如下命令安装NTP软件包 [root@ ~]# yum install ntp -y 2.如果只是作为客户端的话,配置则可以非常简单,编 ...

  6. PowerBI与Visio

    前言 如何在Power BI中使用Visio, 刚好最近微软推出了适用于Power BI 的 Visio自定义可视化对象预览,分享给大家. 我们先看一下效果:    通过自定义可视化对象,将Visio ...

  7. Gym 100712

    我的作用:增加罚时. noip380分大佬全程带飞出了10T,可惜被我搞的罚时太高了... 那啥,你会发现java代码有两种风格,嗯两个人,c++自然就是自招大佬了... A:大水题略 B:(不是我写 ...

  8. JS setAttribute兼容

    问题和表现: 最近实践中遇到的问题,setAttribute()设置在IE7中,无法设置style等属性.这样就对设置样式带了很大的困扰,例如绑定点击事件来隐藏元素,setAttribute(”sty ...

  9. 微信原始坐标转换成百度坐标 lat lng

    如有帮到你记得结合我这篇博客里的方法.... http://www.cnblogs.com/zc290987034/p/8294988.html {:wx_jssdk_config("fal ...

  10. JavaScript基础知识(数据类型)

    数据类型 布尔:true/fasle console.log(typeof true);// "boolean" Number : true -->1 false --> ...