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

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. Keil常见错误汇总及处理方式

    1. warning: #767-D: conversion from pointer to smaller integer 解释:将指针转换为较小的整数 影响:可能造成的影响:容易引起数据截断,造成 ...

  2. 【Ansible 文档】提示、推荐、注意事项

    1. 查看 详细 信息 如果你想要查看成功模块和不成功的详细输出,使用 --verbose 标识 2. 检查 playbook 的语法 使用 ansible-playbook 的 --syntax-c ...

  3. golang []byte和string相互转换

    测试例子 package main   import (     "fmt" )   func main() {     str2 := "hello"     ...

  4. BTREE这种Mysql默认的索引方式,具有普遍的适用性

    文章转自 https://blog.csdn.net/caomiao2006/article/details/52145477 Mysql目前主要有以下几种索引方式:FULLTEXT,HASH,BTR ...

  5. strlen的容易tle情况

    for(int i=1;i<=strlen(**);i++ 这很容易tle 因为 strlen很大 int m=strlen(**)

  6. webpack4升级extract-text-webpack-plugin和UglifyJsPlugin问题

    webpack4升级extract-text-webpack-plugin和UglifyJsPlugin问题 1.  使用了extract-text-webpack-plugin插件后,编译出错,代码 ...

  7. PAT A1109 Group Photo (25 分)——排序

    Formation is very important when taking a group photo. Given the rules of forming K rows with N peop ...

  8. CMM:软件成熟度模型

    周末在家闲来无事,泡咖啡看书,正好看到了关于CMM的相关资料,分享出来,也当做学习笔记... 一.CMM简介 CMM,英文全称为Capability Maturity Model for Softwa ...

  9. ESP8266使用详解(AT,LUA,SDK)

    https://www.cnblogs.com/yangfengwu/p/10100152.html             8266综合开发教程(LUA) https://www.cnblogs.c ...

  10. PHPStorm FTP upload could not change to work directory 无法更改目录

    使用PHPStorm 2016 2.2版本 设置代码及时上传的时候遇到了这个问题,无法上传代码. 配置好了FTP之后去测试,是正常的,如下图一所示,也开启了那个被动模式(见图二),但是去上传代码的时候 ...