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 ...
随机推荐
- IDEA2018.2破解方法
前言 之前也试过多种方式,但是总是使用了一会儿又需要破解,今天又找了一个,不知道可以使用多久. 目前看是可以破解开的,所以分享一下. 适用于JetBrain旗下版本为2.3或2.4的所有产品 一.在 ...
- String 类型的值能够被反射改变从而引发的意外事件
今天刷技术文章,遇到了一个问题,用 Java 反射机制去修改 String 变量的值,出于深入研究,就发现了一个问题,即,用初始值比较修改后的值,用 == or .equals() 方法,出现了相等的 ...
- 恒生UFX交易接口基本介绍说明
1.恒生UFT和UFX有什么区别? UFT是一个极速交易系统,UFX是一个统一接入系统.交易系统很显然是可以进行股票交易的,UFX是所有后台交易系统的接入系统,不管后台是什么样子的交易系统都是可以通过 ...
- Q - Girls and Boys
来源poj1068 In the second year of the university somebody started a study on the romantic relations be ...
- window10安装composer
第一步: 在https://getcomposer.org/download/页面下的Manual Download里下载最新的版本. 下载下来的是composer.phar文件,把这个文件放在你的p ...
- [ACM-ICPC 2018 徐州赛区网络预赛][D. Easy Math]
题目链接:Easy Math 题目大意:给定\(n(1\leqslant n\leqslant 10^{12}),m(1\leqslant m\leqslant 2*10^{9})\),求\(\sum ...
- 5. 文件上传下载 与 db数据库
文件上传 formidable multer npm i formidable multer 如何使用见: https://www.npmjs.com/ util.inspect 自己查 文件上传:表 ...
- PHP7.1安装xdebug
一.前言1. Xdebug 简介Xdebug 是一个开放源代码的 PHP 程序调试器(即一个Debug工具),可以用来跟踪,调试和分析PHP程序的运行状况.当前最新版本为 Xdebug 2.5.0. ...
- 怎么访问不在网站目录下文件(iis虚拟目录设置)
很多时候,上传的文件多了,架设服务器当初设定的主目录所在盘空间往往就不够了,怎么办?这就需要设置虚拟目录.虚拟目录就是将其他目录以映射的方式虚拟到该FTP服务器的主目录下,这样,一个FTP服务器的主目 ...
- (转)JVM中的OopMap(zz)
原文地址: http://www.cnblogs.com/strinkbug/p/6376525.html 在读周智明的深入理解JVM虚拟机时,关于枚举根节点/安全点这部分感觉书上写的不是太明白,找了 ...