问了学长,感觉还是很迷啊,不过懂了个大概,这个翻转操作,实质不就是在序列后面加上前面部分比如

bw | wwbwwbw  操作过后 wbwbwwbww

而 bw | wwbwwbwbw 这样我们就知道这样的实质了,因此我们只需要把序列再次倍增,求最长的间隔序列即可

#include<iostream>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<map>
using namespace std;
int main(){
string a;
while(cin>>a){
int len1=a.length();
a=a+a;
int len=a.length();
int sum=;
int ans=;
for(int i=;i<len-;i++){
if (a[i]!=a[i+]){
sum++;
ans=max(ans,sum);
}else {
sum=;
}
}
ans=min(len1,ans);
cout<<ans<<endl;
}
return ;
}

Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)-C. Plasticine zebra的更多相关文章

  1. Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) -B C(GCD,最长连续交替序列)

    B. Weakened Common Divisor time limit per test 1.5 seconds memory limit per test 256 megabytes input ...

  2. D. Recovering BST Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)

    http://codeforces.com/contest/1025/problem/D 树 dp 优化 f[x][y][0]=f[x][z][1] & f[z+1][y][0] ( gcd( ...

  3. Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) B. Weakened Common Divis

    题目链接 让你找一个数,使得这个数,可以被每个二元组的两个数中的一个数整除. 先将第一个二元组的两个数质因数分解一下,分解的质数加入set中,然后,对剩下的n-1个二元组进行遍历,每次遍历到的二元组对 ...

  4. Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)

    A : A. Doggo Recoloring time limit per test 1 second memory limit per test 256 megabytes input stand ...

  5. Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) 题解

    真心简单的一场比赛 就是坑比较多(自己太蠢) A是一个水题 3分钟的时候过了 B也是一个比较简单的题 类似的套路见得多了 但是我当时可能比较困 想了一会才想出来 19分钟的时候过掉了 C同样很显然 性 ...

  6. 【Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) C】

    [链接] 我是链接,点我呀:) [题意] 给你一个字符串s. 让你在其中的某一些位置进行操作.. 把[1..i]和[i+1..n]翻转. 使得里面01交替出现的那种子串的长度最长. [题解] 可以用a ...

  7. 【Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) A】 Doggo Recoloring

    [链接] 我是链接,点我呀:) [题意] 你可以把出现次数大于1的颜色换成其他颜色. 问你最后能不能全都变成同一种颜色 [题解] 判断一下有没有出现次数大于1的就好. 有的话.显然可以一直用它变颜色. ...

  8. 【Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) B】Weakened Common Divisor

    [链接] 我是链接,点我呀:) [题意] 给你n个数对(ai,bi). 让你求一个大于1的数字x 使得对于任意的i x|a[i] 或者 x|b[i] [题解] 求出第一个数对的两个数他们有哪些质因子. ...

  9. E - Down or Right Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)

    http://codeforces.com/contest/1023/problem/E 交互题 #include <cstdio> #include <cstdlib> #i ...

随机推荐

  1. HDU ACM 1856 More is better(并查集)

    [题目链接]http://acm.hdu.edu.cn/showproblem.php?pid=1856 [解题思路]给的数据有点大,干脆少开点数组,直接上set存储有朋友的孩子的编号,同时根据编号初 ...

  2. ORA-12538;ORA-12154;使用PL/SQL dve无法连接远程服务器上的oracle数据库,同时本机上也安装了一个oracle数据库

    问题描述:本人使用PL/SQL dve连接远程服务器上的oracle数据库,一直是没有问题的.我想提高下自己在数据库方面的能力就在自己的笔记本上安装了一个oracle数据库实例,安装并配置好之后,使用 ...

  3. awk实战演示

    awk:报告生成器,格式化文本输出. 我们一般使用的awk命令其实就是gawk,在centos7系统下,awk是gawk的链接文件. 基本用法:gawk [options] 'program'  FI ...

  4. django —— MVT模型

    转载----

  5. 三种方法更改MAC OS X下的HOSTS文件

    1.终端更改 用程序里面打开终端(terminal),输入 sudo vi /etc/hosts 然后提示输入系统密码 hosts文件就自动打开了 接着输入 i 进入编辑模式 将添加的网站,ip拷贝进 ...

  6. WPF防止重复运行实例

    1.方法一 在app.xaml.cs下添加如下代码: /// <summary> /// App.xaml 的交互逻辑 /// </summary> public partia ...

  7. LinkedList与ArrayList的区别

    我们都知道LinkedList和ArrayList相比: 1.LinkedList插入删除相对较快,而查询较慢: 2.ArrayList插入删除相对较慢,而查询很快(详细可查看从源码的角度分析List ...

  8. Redis后台监控与管理CacheCloud

    CacheCloud环境需求 Java 7 Maven 3 MySQL Redis 3 具体用法可参考:https://cachecloud.github.io 1.下载CacheCloud 官网ht ...

  9. SQL Server中将查询结果转换为Json格式脚本

    这篇文章主要介绍了SQL Server中将查询结果转换为Json格式脚本分享,本文直接给出实现代码,需要的朋友可以参考下 原文地址:http://www.jb51.net/article/61462. ...

  10. ethereum/EIPs-158 State clearing 被EIP-161取代

    eip title author type category status created superseded-by 158 State clearing Vitalik Buterin Stand ...