gym-10135I
题意:和H差不多,这个是找字符串中最长的镜像字串;
思路:一样的思路,标记下;
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#define ll long long
using namespace std;
int main()
{
char s[];
char s1[]="WTYUIOAHXVM";
int flag[];
int ans;
int t;
int len;
int len1;
int sum,sum1;
int maxx;
int left,right;
cin>>t;
while(t--)
{
cin>>s;
len=strlen(s);
len1=strlen(s1);
memset(flag,,sizeof(flag));
for(int i=;i<len;i++)
{
for(int j=;j<len1;j++)
if(s[i]==s1[j])
{
flag[i]=;break;
}
}
ans=;
for(int i=;i<=len-;i++)
{
if(flag[i])
{
left=i-;right=i+;sum=;
while(left>=&&right<len)
{
if(s[left]==s[right]&&flag[left]&&flag[right])
{
sum+=;
left--;
right++;
}
else
break;
}
left=i;right=i+;sum1=;
while(left>=&&right<len)
{
if(s[left]==s[right]&&flag[left]&&flag[right])
{
sum1+=;
left--;
right++;
}
else
break; } maxx=max(sum,sum1);
ans=max(ans,maxx);
}
else
continue;
}
cout<<ans<<endl;
}
return ;
}
gym-10135I的更多相关文章
- ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力
Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS Memory Limit:65536KB 64bit IO Fo ...
- ACM: Gym 101047K Training with Phuket's larvae - 思维题
Gym 101047K Training with Phuket's larvae Time Limit:2000MS Memory Limit:65536KB 64bit IO F ...
- ACM: Gym 101047E Escape from Ayutthaya - BFS
Gym 101047E Escape from Ayutthaya Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I6 ...
- ACM: Gym 101047B Renzo and the palindromic decoration - 手速题
Gym 101047B Renzo and the palindromic decoration Time Limit:2000MS Memory Limit:65536KB 64 ...
- Gym 101102J---Divisible Numbers(反推技巧题)
题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...
- Gym 100917J---Judgement(01背包+bitset)
题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...
- Gym 100917J---dir -C(RMQ--ST)
题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...
- Gym 101102D---Rectangles(单调栈)
题目链接 http://codeforces.com/gym/101102/problem/D problem description Given an R×C grid with each cel ...
- Gym 101102C---Bored Judge(区间最大值)
题目链接 http://codeforces.com/gym/101102/problem/C problem description Judge Bahosain was bored at ACM ...
- 2016"百度之星" - 初赛(Astar Round2A)Gym Class(拓扑排序)
Gym Class Accepts: 849 Submissions: 4247 Time Limit: 6000/1000 MS (Java/Others) Memory Limit: 65 ...
随机推荐
- python redis存入字典序列化存储
在python中通过redis hset存储字典时,必须主动把字典通过json.dumps()序列化为字符串后再存储, 不然hget获取后将无法通过json.loads()反序列化为字典 序列化存储 ...
- Python 学习 第十五篇:模块搜索路径和包导入
在导入自定义的模块时,除了指定模块名之外,也需要指定目录,由于Python把目录称作包,因此,这类导入被称为包导入.包导入把计算机上的目录变成Python的命名空间,而目录中所包含的子目录和模块文件则 ...
- MySQL表结构变更,不可不知的Metadata Lock
在线上进行DDL操作时,相对于其可能带来的系统负载,其实,我们最担心的还是MDL其可能导致的阻塞问题. 一旦DDL操作因获取不到MDL被阻塞,后续其它针对该表的其它操作都会被阻塞.典型如下,如阻塞稍久 ...
- jQuery 初识 筛选器 属性选择器
---------------------------大事使我们惊讶,小事使我们沮丧,久而久之,我们对这二者都会习以为常. 一 jQuery是什么? [1] jQuery由美国人John Resi ...
- vue文档全局api笔记2
1.Vue.filter( id, [definition] ) 在组件内注册 <template> <div id="app"> <div clas ...
- Git简易的命令入门
Git 全局设置: git config --global user.name "kszsa" git config --global user.email "duyon ...
- Final Destination II -- 矩阵快速幂模板题
求f[n]=f[n-1]+f[n-2]+f[n-3] 我们知道 f[n] f[n-1] f[n-2] f[n-1] f[n-2] f[n-3] 1 1 ...
- Python—json模块
用于序列化的两个模块 json,用于字符串 和 python数据类型间进行转换 pickle,用于python特有的类型 和 python的数据类型间进行转换 Json模块提供了四个功能:dumps. ...
- Python api接口和SQL数据库关联
数据库表创建 服务器环境配置.连接 .操作.数据库 API接口 原则:
- ES6 Promise 详解
一.概念 Promise,从语法上来讲,它是一个对象,是一个构造函数,可以获取 异步操作 的信息. 简单来讲,就是用同步的方式写异步代码,用来解决回调问题. 二.特点 Promise 对象有两个特点: ...