题意:

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. mysql 从陌生到熟练之----数据库备份恢复的实现方法

    mysql 从陌生到熟练之----数据库备份恢复的实现方法 MySQL数据库使用命令行备份|MySQL数据库备份命令 例如: 数据库地址:127.0.0.1 数据库用户名:root 数据库密码:roo ...

  2. UIPopoverController

    if (popOver == nil) { popOver = [[UIPopoverController alloc] initWithContentViewController:viewVC]; ...

  3. NSURL初始化失败

    服务端给返回的网页加载不出来,仔细一看,url是空的!!为什么呢. 示例: NSString *urlStr = @"http://服务器返回带有汉字的url字符串.com"; N ...

  4. 【转】 VC中TCP实现 异步套接字编程的原理+代码

    所谓的异步套接字编程就是  调用了 如下函数   WSAAsyncSelect   设置了 套接字的状态为异步,有关函数我会在下面详细介绍... 异步套接字解决了 套接字编程过程中的堵塞问题 .... ...

  5. matplotlib绘图(三)

    matplotlib中2D图形的绘制 直方图 直方图的参数只有一个x,不像条形图需要传入x,y 直方图作用:是统计x在某个区间上出现的次数 直方图是条形图的一种形式 hist()的参数: #bins ...

  6. MYSQL存储过程,函数,光标

    存储过程 MySQL中,创建存储过程的基本形式如下: CREATE PROCEDURE sp_name ([proc_parameter[,...]]) [characteristic ...] ro ...

  7. 201621123080《JAVA程序设计》第八周学习总结

    作业08-集合 1. 本周学习总结 2. 书面作业 1. ArrayList代码分析 1.1 解释ArrayList的contains源代码 根据代码,首先在源数组里找到下标,若下标符合>=0 ...

  8. 12Vim在系统配置中的应用示例

    Vim 在系统配置中的应用示例 1. 配置主机名称 为了便于咱局域网中查找某台特定的主机,后者对主机进行区分,除了要有IP地址外,还要为主机配置一个主机名,主机名之间可以通过这个类似于域名的名称来相互 ...

  9. drf 认证功能

    drf(django rest-framework)认证组件 复习 HyperlinkedIdentityField ​```python 功能:快速生成连接 1. publish = seriali ...

  10. web开发框架tornado

    在server.py文件中 import tornado.web import tornado.ioloop import tornado.httpserver import config from ...