Codeforces #505(div1+div2) C Plasticine zebra
题意:给你一段字符串,可以选择任意多的位置,每个位置会反转两边的字符串,问交错的字符串最长是多长?
思路:找规律,仔细分析样例1.假设位置为 1 2 3 4 5 6 7 8 9,反转之后会发现答案是7 8 9 1 2 3 4 5 6 ,其中答案串是7 8 9 1 2,所以可以把原字符串复制一份粘在原字符串后面,找最长的交错串即可。
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<map>
#include<set>
#include<bitset>
#include<map>
#include<queue>
#include<cmath>
#include<stack>
#include<vector>
#define INF 0x3f3f3f3f
#define pii pair<int,int>
#define LL long long
#define mk(a,b) make_pair(a,b)
#define rep(i,n) for(int i=1;i<=n;i++)
using namespace std;
char s[200010];
int main(){
scanf("%s",s+1);
int n=strlen(s+1);
rep(i,n)s[i+n]=s[i];
int tmp=1,ans=0;
rep(i,2*n-1){
if(s[i+1]!=s[i])
tmp++;
else{
ans=max(ans,tmp);
tmp=1;
}
}
ans=max(ans,tmp);
printf("%d\n",min(ans,n));
}
Codeforces #505(div1+div2) C Plasticine zebra的更多相关文章
- Codeforces #505(div1+div2) D Recovering BST
题意:给你一个升序的数组,元素之间如果gcd不为1可以建边,让你判断是否可以建成一颗二叉搜索树. 解法:dp,首先建图,然后进行状态转移.因为如果点k左端与i相连,右端与k相连,则i和k可以相连,同时 ...
- Codeforces #505(div1+div2) B Weakened Common Divisor
题意:给你若干个数对,每个数对中可以选择一个个元素,问是否存在一种选择,使得这些数的GCD大于1? 思路:可以把每个数对的元素乘起来,然后求gcd,这样可以直接把所有元素中可能的GCD求出来,从小到大 ...
- Codeforces #504(div1+div2) 1023D Array Restoration(线段树)
题目大意:给你一个数组,数组是经过q次区间覆盖后的结果,第i次覆盖是把区间内的值赋值为i,其中有若干个地方数值未知(就是0),让你判断这个数组是否可以经过覆盖后得到的,如果可以,输出任意一种可行数组. ...
- codeforces#505--C Plasticine Zebra
C. Plasticine zebra time limit per test 1 second memory limit per test 256 megabytes input standard ...
- 【前行&赛时总结】◇第4站&赛时9◇ CF Round 513 Div1+Div2
◇第4站&赛时9◇ CF Round 513 Div1+Div2 第一次在CF里涨Rating QWQ 深感不易……作blog以记之 ( ̄▽ ̄)" +Codeforces 的门为你打 ...
- Codeforces Round #539 div2
Codeforces Round #539 div2 abstract I 离散化三连 sort(pos.begin(), pos.end()); pos.erase(unique(pos.begin ...
- 【前行】◇第3站◇ Codeforces Round #512 Div2
[第3站]Codeforces Round #512 Div2 第三题莫名卡半天……一堆细节没处理,改一个发现还有一个……然后就炸了,罚了一啪啦时间 Rating又掉了……但是没什么,比上一次好多了: ...
- codeforces 407 div1 B题(Weird journey)
codeforces 407 div1 B题(Weird journey) 传送门 题意: 给出一张图,n个点m条路径,一条好的路径定义为只有2条路径经过1次,m-2条路径经过2次,图中存在自环.问满 ...
- codeforces 407 div1 A题(Functions again)
codeforces 407 div1 A题(Functions again) Something happened in Uzhlyandia again... There are riots on ...
随机推荐
- 20180907_网络差_天安微信token请求超时
一.异常现象 token请求时,显示请求超时. 二.原因分析 这个异常有如下几个原因: (1)服务器没有开通 qyapi.weixin.qq.com 的外网权限 (2)服务器网络太慢 三.异常解决 ...
- @angular/cli项目构建--http(2)
客户端GET设置参数查询: search() { const params = new HttpParams() .set('userName', this.userName) .set('fullN ...
- UVA 10417 Gift Exchanging
#include <iostream> #include <cstring> #include <stdio.h> #include <math.h> ...
- python的编解码问题
http://blog.chinaunix.net/uid-27838438-id-4227131.html
- linux内核图形配置疑难解决
配置linux内核是遇到的问题:(1)问题一make gconfig * * Unable to find the GTK+ installation. Please make sure that * ...
- 设置eclipse中jsp/html文件好看的自动排版
注:本文转载于ieayoio,原文链接:https://blog.csdn.net/ieayoio/article/details/49930587#8912689 eclipse中jsp文件代码的排 ...
- 一根Express Route同时支持ARM和ASM的VNET
ARM模式的Azure管理模式在China Azure上已经正式落地了.今后在China Azure上应该主要以ARM的模式创建VM了. 并且目前Express Route也已经可以在ARM模式下创建 ...
- POJ1063Cable master(二分搜索)
Cable master Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 36288 Accepted: 7743 Des ...
- VisualGDB系列8:使用VS创建CMake Linux项目
根据VisualGDB官网(https://visualgdb.com)的帮助文档大致翻译而成.主要是作为个人学习记录.有错误的地方,Robin欢迎大家指正. 本文介绍如何使用VS来创建.构建.调试一 ...
- 使用Spring AMQP开发消费者应用
前一篇中我们介绍了使用RabbitMQ Java Client访问RabbitMQ的方法.但是使用这种方式访问RabbitMQ,开发者在程序中需要自己管理Connection,Channel对象,Co ...