题意:给你一个01串,必须替换一次,且替换的为子串。问换完后,最大01串长度。

 #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
int n,sum = ;
string s;
cin >> n >> s;
char last = s[];
for(int i = ; i < n ; i ++)
{
if(last != s[i])
{
sum ++;
last = s[i];
}
}
if(sum >= n - )
cout << n << endl;
else
cout << sum + << endl;
return ;
}

Codeforces 603A Alternative Thinking的更多相关文章

  1. Codeforces 603A - Alternative Thinking - [字符串找规律]

    题目链接:http://codeforces.com/problemset/problem/603/A 题意: 给定一个 $01$ 串,我们“交替子序列”为这个串的一个不连续子序列,它满足任意的两个相 ...

  2. codeforc 603-A. Alternative Thinking(规律)

    A. Alternative Thinking time limit per test 2 seconds memory limit per test 256 megabytes   Kevin ha ...

  3. 「日常训练」Alternative Thinking(Codeforces Round #334 Div.2 C)

    题意与分析 (CodeForces - 603A) 这题真的做的我头疼的不得了,各种构造样例去分析性质... 题意是这样的:给出01字符串.可以在这个字符串中选择一个起点和一个终点使得这个连续区间内所 ...

  4. Codeforces Gym 100803F There is No Alternative 暴力Kruskal

    There is No Alternative 题目连接: http://codeforces.com/gym/100803/attachments Description ICPC (Isles o ...

  5. Codeforces Round #334 (Div. 2) C. Alternative Thinking 贪心

    C. Alternative Thinking Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/6 ...

  6. 【33.10%】【codeforces 604C】Alternative Thinking

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  7. Codeforces Gym 100002 D"Decoding Task" 数学

    Problem D"Decoding Task" Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com ...

  8. Codeforces 749C. Voting 模拟题

    C. Voting time limit per test: 1 second memory limit per test: 256 megabytes input: standard input o ...

  9. Codeforces Round #296 (Div. 1) C. Data Center Drama 欧拉回路

    Codeforces Round #296 (Div. 1)C. Data Center Drama Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xx ...

随机推荐

  1. javascript禁用与启用select标签(实用版)

    <html><head><script type="text/javascript">function disable()  {  docume ...

  2. ural 1160

    最小生成树  第一次敲 套用几个函数 其实挺容易的 #include <cstdio> #include <cstring> #include <vector> # ...

  3. 建立Clojure开发环境-使用IDEA和Leiningen

    OS: Mac OS X 10.10 IDEA 14.0.2 Community Edition 安装Leiningen 按照http://leiningen.org/的指南安装lein 阅读Lein ...

  4. spark storage之SparkEnv

    此文旨在对spark storage模块进行分析,整理自己所看所得,等以后再整理. ok,首先看看SparkContext中sparkEnv相关代码: private[spark] def creat ...

  5. Android EditText边框颜色的selector 使用focus标记当前填写的框

    案例:当选中一个EditText时,将其边框变为蓝色,其他未被选中的EditText则为灰色. 主界面: <?xml version="1.0" encoding=" ...

  6. codeforces #309 div1 C

    首先我们会发现所有的人构成了一个图 定义相爱为 在一个集合里 定义相恨为 不在一个集合里 很容易发现满足条件的图一定是一个二分图 那么分类讨论如下: 1.如果出现不合法 答案为0 2.如果不是一个二分 ...

  7. 编程添加"作为服务登录”权利(包括例子和API)

    搜索"log on as a service programmatically" https://msdn.microsoft.com/en-us/library/windows/ ...

  8. Git教程之删除文件(8)

    在Git中,删除也是一个修改操作,我们实战一下,先添加一个新文件test.txt到Git并且提交:

  9. java截取url中的值

    Map<String, Object> urlSplit(String data){ StringBuffer strbuf = new StringBuffer(); StringBuf ...

  10. git svn rebase出现了checksum mismatch的错误

    http://stackoverflow.com/questions/3156744/git-svn-rebase-checksum-mismatch This solution was the on ...