Codeforces Round #334 (Div. 2) C. Lieges of Legendre
2015-12-02 17:05
351 查看
题意:给你一个字符串,你可以使得一个连续的01串翻转过来,然后问你最长的01相隔的子序列(不连续)的长度为多少
解:答案一定是max(len+2,n),len为原来01串的最长长度
解:答案一定是max(len+2,n),len为原来01串的最长长度
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; const int maxm=1e5+10; char s[maxm]; int main() { int n; while(scanf("%d",&n)!=EOF) { scanf("%s",s); int len=1; for(int i=1;i<strlen(s);i++) { if(s[i]!=s[i-1]) len++; } printf("%d\n",min(len+2,n)); } return 0; }
相关文章推荐
- Photoshop CC (2015.1) 2015.11.30版
- BZOJ4033: [HAOI2015]T1
- 数字图像处理:第十章 离散图象变换
- Java基本知识(连载)-数组、方法和字符串
- ios_swift 对比懒加载和普通赋值的区别
- 数字图像处理:第九章 线性系统、卷积、傅立叶变换
- Volley
- 命名(code)
- node异步转同步,KO 恶魔金字塔
- 获取当前EXE执行路径
- Android 自定义View (一)
- iOS开发——keychain的使用
- 2.puppet学习笔记:puppet资源file详细介绍
- 性能测试结果分析
- 安装IntelliJ IDEA
- 信息安全系统设计基础实验五:通讯协议设计 20135211李行之 20135216刘蔚然
- 推送技术
- iOS多线程的初步研究(四)-- NSTimer
- 如何防止APP被二次打包
- 用Excel利用RFM模型进行客户细分