题意:

n<=1e5

思路:可以证明答案即为极长交替出现的串长度之和

需要注意其实这个串是一个环,复制后再做

 #include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef vector<int> VI;
#define fi first
#define se second
#define MP make_pair
#define N 2100000
#define MOD 1000000007
#define eps 1e-8
#define pi acos(-1)
#define oo 110000000000000 char a[N],b[N]; int read()
{
int v=,f=;
char c=getchar();
while(c<||<c) {if(c=='-') f=-; c=getchar();}
while(<=c&&c<=) v=(v<<)+v+v+c-,c=getchar();
return v*f;
} void swap(int &x,int &y)
{
int t=x;x=y;y=t;
} ull gcd(ull a, ull b)
{
return a == ? b : gcd(b % a, a);
} int main()
{
// freopen("1.in","r",stdin);
// freopen("1.out","w",stdout);
scanf("%s",a);
int n=strlen(a);
for(int i=;i<=n;i++) b[i]=a[i-];
for(int i=n+;i<=n*-;i++) b[i]=b[i-n];
int m=n*-;
int t=;
int w=;
int ans=;
while(t<n)
{
t++;
if(w<t) w=t;
int tmp=;
while(w+<=m&&w+<=t+n-&&b[w]!=b[w+])
{
w++; tmp++;
}
// printf("%d %d\n",t,w);
ans=max(ans,tmp);
}
// for(int i=1;i<=m;i++) printf("%c",b[i]);
printf("%d\n",ans);
return ;
}

【CF1025C】Plasticine zebra(模拟)的更多相关文章

  1. CF1025C Plasticine zebra 思维 字符串

    Plasticine zebra time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  2. CF1025C Plasticine zebra【环状字符串/思维】

    给你一个长度为 \(\left|s\right|\) 的01串 \(s\) ,每次操作你可以任选一个 \(k\) ,使01串的 \([1,k]\) 和 \((k,\left|s\right|]\) 分 ...

  3. CF1025C Plasticine zebra

    思路: 不要被骗了,这个操作实际上tm是在循环移位. 实现: #include <bits/stdc++.h> using namespace std; int main() { stri ...

  4. codeforces#505--C Plasticine Zebra

    C. Plasticine zebra time limit per test 1 second memory limit per test 256 megabytes input standard ...

  5. CF 1025C Plasticine zebra

    昨晚忘记判只有一个字符的情况fst了呜呜呜 挺有趣的题,昨晚连刚带猜弄出结论 考虑答案的取值,最优答案可能是一个后缀,或者是一个前缀,或者是一个后缀加上前缀 那么翻转之后最优答案的可选值就有了1的前缀 ...

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

    问了学长,感觉还是很迷啊,不过懂了个大概,这个翻转操作,实质不就是在序列后面加上前面部分比如 bw | wwbwwbw  操作过后 wbwbwwbww 而 bw | wwbwwbwbw 这样我们就知道 ...

  7. Codeforces #505(div1+div2) C Plasticine zebra

    题意:给你一段字符串,可以选择任意多的位置,每个位置会反转两边的字符串,问交错的字符串最长是多长? 思路:找规律,仔细分析样例1.假设位置为 1 2 3 4 5 6 7 8 9,反转之后会发现答案是7 ...

  8. CF C. Plasticine zebra (思维)

    题意: 是输入一个只有'w','b'的字符串,可以对他的任意位置切割成两个子串,切割后的右边的子串翻转后再和左边的子串拼起来会得到一个新的字符串,操作次数不限,问能得到的字符串中wb交替出现的最大的长 ...

  9. Codeforces Round #505 Div. 1 + Div. 2

    传送门:>Here< 从来没打过\(CF\)(由于太晚了)-- 不知道开学了以后有没有机会能够熬夜打几场,毕竟到现在为止都是\(unrated\)好尴尬啊~ 今天早上打了几题前几天的比赛题 ...

随机推荐

  1. Livid : 在 26 岁时写给 18 岁的自己

    转载自: https://livid.v2ex.com/essays/2012/01/24/a-letter-from-26-to-18.html 在 26 岁时写给 18 岁的自己 Jan 24, ...

  2. c# 输出不同时间的格式

    C#时间/日期格式大全,C#时间/日期函数大全 有时候我们要对时间进行转换,达到不同的显示效果 默认格式为:2005-6-6 14:33:34 如果要换成成200506,06-2005,2005-6- ...

  3. laravel5 使用try catch

    在laravel5中使用以下代码并没有捕获异常 try{ var_dump($val); }catch (Exception $e){ var_dump($e); }  Laravel 5 时代控制器 ...

  4. 求数组中两两相加等于20的组合(Python实现)

    题目 求数组中两两相加等于20的组合. 例:给定一个数组[1, 7, 17, 2, 6, 3, 14],这个数组中满足条件的有两对:17+3=20, 6+14=20. 解析 分为两个步骤: 先采用堆排 ...

  5. markdown快捷键

    分组 功能 操作 快捷键 设置标题 一级标题 Heading1 Ctrl+1 二级标题 Heading2 Ctrl+2 三级标题 Heading3 Ctrl+3 四级标题 Heading4 Ctrl+ ...

  6. Docker初认识(一)

    1)简介 1.1)什么是Docker Docker 最初是 dotCloud 公司创始人 Solomon Hykes 在法国期间发起的一个公司内部项目,它是基于 dotCloud 公司多年云服务技术的 ...

  7. Java技术——Java泛型详解

    .为什么需要泛型 转载请注明出处:http://blog.csdn.net/seu_calvin/article/details/52230032 泛型在Java中有很重要的地位,网上很多文章罗列各种 ...

  8. luogu2394 yyy loves Chemistry I

    练习 #include <iostream> #include <cstdio> using namespace std; long double a; int main(){ ...

  9. canvas 动画库 CreateJs 之 EaselJS(下篇)

    本文来自网易云社区 作者:田亚楠 继承 对应原文:Inheritance 我们可以继承已有的「显示对象」,创建新的自定义类.实现方法有很多种,下面介绍其中之一. 举例:实现一个继承于 Containe ...

  10. [POJ 1000] A+B Problem 经典水题 C++解题报告 JAVA解题报告

        A+B Problem Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 311263   Accepted: 1713 ...