codeforces 982A Row
题意:
一个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的更多相关文章
- Educational Codeforces Round 6 C. Pearls in a Row
Educational Codeforces Round 6 C. Pearls in a Row 题意:一个3e5范围的序列:要你分成最多数量的子序列,其中子序列必须是只有两个数相同, 其余的数只能 ...
- codeforces A. Difference Row
link:http://codeforces.com/contest/347/problem/A 开始看起来很复杂的样子,但是刚写下样例,就发现因为中间的都消去了,其实起作用的就是最大值和最小值=_= ...
- codeforces A. Difference Row 解题报告
题目链接:http://codeforces.com/problemset/problem/347/A 题目意思:给出一个序列 a1, a2, ..., an , 通过重排序列,假设变成 x1, x2 ...
- 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 ...
- Pearls in a Row CodeForces 620C 水题
题目:http://codeforces.com/problemset/problem/620/C 文章末有一些测试数据仅供参考 题目大意 给你一个数字串,然后将分成几个部分,要求每个部分中必须有一对 ...
- 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 ...
- 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 ...
- codeforces B. Trees in a Row 解题报告
题目链接:http://codeforces.com/problemset/problem/402/B 题目意思:给出n个数和公差k,问如何调整使得ai + 1 - ai = k.(1 ≤ i < ...
- 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 ...
随机推荐
- Android利用Mediapalyer播放本地资源文件声音
首先在res下创建raw,然后将mp3音乐拷贝到raw下 直接贴代码吧 //开始播放声音 public class PlayVoice { private static MediaPlayer med ...
- swoole 基础知识
$host = 127.0.0.1 监听本地ip $host = 255.3.258.139 监听外网的某个ip $host= 0.0.0.0 监听所有ip $ws = new swoole_we ...
- jmeter3.0下载及安装
http://blog.csdn.net/shizhiailian/article/details/52443169 下载: https://archive.apache.org/dist/jmete ...
- dos 打开计算机管理
一. 首先打开[运行]程序:二. 运行中输入‘CMD’:三. 然后在上面输入‘compmgmt.msc’,就可以打开“计算机管理”命令了.
- Adas术语简称
V2X: DSRC:专用短程通信(DSRC)的公用频谱信道交换数据
- python str byte 转换
# bytes object b = b"example" # str object s = "example" # str to bytes bytes(s, ...
- 【消灭代办】第5周 - null拷贝,input自适应,进度条加载,颜色随机值
2018.12.10 代办一:javascript中js怎么拷贝null的值 null属于简单类型的数值,直接进行拷贝即可: 2018.12.11 代办二:怎么让input自适应宽度? 这样是写下代办 ...
- 使用PsExec获取shell执行命令
PsExec PsExec是pstools工具组套件的一部分,确成为了渗透利器,下载地址:点击这里下载 连接shell 我的Windows Server 2012默认打开域网络防火墙的时候,是不能连接 ...
- keras入门
自己要搞深度学习,正好手上有本keras之父写的深度学习书,于是就从keras入手吧.看了一个电影的二分类问题,确实很简单,可以熟悉深度学习的流程.首先熟悉了结果keras的模块,如model,Seq ...
- python文档自动翻译
关键方法 提取文档内容 读取TXT文档 txt文档的读取很简单,直接用python自带的open()方法就好,代码如下所示: # 读取TXT文档 def read_txt(path): '''实现TX ...