题意:

一个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常用排序算法学习

    第四百一十五节,python常用排序算法学习 常用排序 名称 复杂度 说明 备注 冒泡排序Bubble Sort O(N*N) 将待排序的元素看作是竖着排列的“气泡”,较小的元素比较轻,从而要往上浮 ...

  2. ubuntu下core file文件生成及调试

    1.简介:corefile 是Linux下程序崩溃时生成的文件,可以用来分析程序崩溃的原因,因为它内部包含了程序崩溃时的堆栈信息. 2.corefile的设置 默认情况下,程序崩溃是不会生成coref ...

  3. 蜕变成蝶~Linux设备驱动之按键设备驱动

    在上述的驱动系列博客中,我们已经了解了关于阻塞和非阻塞.异步通知.轮询.内存和I/O口访问.并发控制等知识,按键设备驱动相对来说是比较简单的,本章内容可以加深我们对字符设备驱动架构.阻塞与非阻塞.中断 ...

  4. Redis介绍和安装

    一. Redis的介绍 Redis 是一个Key-Value存储的系统:它支持存储的value类型有string(字符串),list(列表),set(集合),zset(有序集合):为了保证效率:数据都 ...

  5. JS设计模式——观察者模式(通俗易懂)

    Observer模式的概念 Observer模式是行为模式之一,它的作用是当一个对象的状态发生变化时,能够自动通知其他关联对象,自动刷新对象状态. Observer模式提供给关联对象一种同步通信的手段 ...

  6. 远程连接服务器影像文件进行服务发布以及问题解决【the data item is inaccessible】

    场景模拟: 本机安装有arcgis desktop以及arcgis server10.1,server的站点账号为arcgis. 需要发布影像服务并进行切片,使用的影像数据存放在远程服务器上,影像较大 ...

  7. LeetCode - Subarray sum equals k

    Given an array of integers and an integer k, you need to find the total number of continuous subarra ...

  8. Spring Boot Starter 的基本封装

    1)spring-boot-starter这是Spring Boot的核心启动器,包含了自动配置.日志和YAML. 2)spring-boot-starter-amqp通过spring-rabbit来 ...

  9. vue-cli3实现分环境打包步骤(给不同的环境配置相对应的打包命令)

    在vue-cli3的项目中,npm run serve时会把process.env.NODE_ENV设置为‘development’:npm run build 时会把process.env.NODE ...

  10. python DBUtils 线程池 连接 Postgresql(多线程公用线程池,DB-API : psycopg2)

    一.DBUtils DBUtils 是一套允许线程化 Python 程序可以安全和有效的访问数据库的模块,DBUtils提供两种外部接口: PersistentDB :提供线程专用的数据库连接,并自动 ...