题意:

一个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. 5.动态代理AOP实现-DynamicProxy模式

    通过动态代理模式Interceptor实现在RegUser()方法本身业务前后加上一些自己的功能,如:PreProceed和PostProceed,即不修改UserProcessor类又能增加新功能 ...

  2. 树莓派apache2.4源码包安装

    1.安装apr-1.6.3.tar.gz apr-util-1.6.1.tar.bz2 httpd-2.4.34.tar.gz (源码包下载centos7的就行,树莓派版本官方debian) 2.问题 ...

  3. linux windows安装python的最佳方式,miniconda

    1.在linux安装python文章很多,但是步骤很多,没搞好还会把yum命令弄坏,要修复.这件事就发生在我身上,准确说不是我造成的,是总监自己安装python造成yum损坏的,然后需要运维去百度修改 ...

  4. 【AI】神经网络基本词汇

    neural networks 神经网络activation function 激活函数hyperbolic tangent 双曲正切函数bias units 偏置项activation 激活值for ...

  5. react build后直接从浏览器打开

    存在两个问题 一,资源文件路径 config/paths.js 这里原来的.pathname:'/', 改成.pathname:'./' function getServedPath(appPacka ...

  6. csrf 攻击和防御

    CSRF概念:CSRF跨站点请求伪造(Cross—Site Request Forgery),跟XSS攻击一样,存在巨大的危害性,你可以这样来理解:       攻击者盗用了你的身份,以你的名义发送恶 ...

  7. mybatis09--自连接一对多查询

    查询导师 下面的所有 老师的信息! 创建实体类 和对应的数据库 /** *导师的实体类 */ public class Teacher { private Integer id; private St ...

  8. 下载JDK开发工具包

    实例说明 开发java程序必须有Java开发环境,即jdk开发工具包,这个工具包包含了编译.运行.调试等关键的命令.运行Eclipse.NetBeans等开发工具也需要有jdk或jre的支持. 关键技 ...

  9. Linux上传文件与执行

    ls ——查看文件夹 mkdir——新建文件夹 cd:——进入文件 nohup python3 文件名.py & ——让代码在后台运行 ps -aux | grep 文件——查看进程 ps-a ...

  10. vue-router 进阶

    简单回顾一下vue基础部分 动态路由匹配 路由配置方法 export default new Router({ routes: [ { path: '/router01/:name', name: ' ...