题意:和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的更多相关文章

  1. 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 ...

  2. ACM: Gym 101047K Training with Phuket's larvae - 思维题

     Gym 101047K Training with Phuket's larvae Time Limit:2000MS     Memory Limit:65536KB     64bit IO F ...

  3. ACM: Gym 101047E Escape from Ayutthaya - BFS

    Gym 101047E Escape from Ayutthaya Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I6 ...

  4. ACM: Gym 101047B Renzo and the palindromic decoration - 手速题

     Gym 101047B  Renzo and the palindromic decoration Time Limit:2000MS     Memory Limit:65536KB     64 ...

  5. Gym 101102J---Divisible Numbers(反推技巧题)

    题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...

  6. Gym 100917J---Judgement(01背包+bitset)

    题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...

  7. Gym 100917J---dir -C(RMQ--ST)

    题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...

  8. Gym 101102D---Rectangles(单调栈)

    题目链接 http://codeforces.com/gym/101102/problem/D problem  description Given an R×C grid with each cel ...

  9. Gym 101102C---Bored Judge(区间最大值)

    题目链接 http://codeforces.com/gym/101102/problem/C problem description Judge Bahosain was bored at ACM ...

  10. 2016"百度之星" - 初赛(Astar Round2A)Gym Class(拓扑排序)

    Gym Class  Accepts: 849  Submissions: 4247  Time Limit: 6000/1000 MS (Java/Others)  Memory Limit: 65 ...

随机推荐

  1. Jmeter+ant+jenkins集成

    已有jmeter.*.jmx脚本 一.jmeter+ant 1.下载安装ant(检查是否安装成功) 2.将 JMeter 所在目录下 extras 子目录里的 ant-JMeter-1.1.1.jar ...

  2. Objective-C Programming The Big Nerd Ranch Guide 笔记 19-37

    Properties are either atomic or nonatomic, The difference has to do with multithreading. atomic is t ...

  3. 使用Python的http.server实现一个简易的Web Api对外提供HanLP拼音转换服务

    由于采集省市区镇数据需要对地名进行拼音转换,由于第三方高准确度接口对IP进行了限制,处理大量数据变得异常缓慢. 使用了一个折中的办法,省市区 3级(3千+)用高准确度接口(几乎没有拼错的地名),镇级( ...

  4. IT江湖--这个冬天注定横尸遍野

    今年江湖大事繁起,又至寒冬,冻的不仅是温度,更是人心. 这两天上班途中看到多个公众号和媒体发了很多 "XXX公司裁员50%" 等等诸如此类的文章,也真是撼动人心.寒冬,比以往来的更 ...

  5. OO博客作业3:第9-11周作业总结

    一.总结介绍规格化设计的大致发展历史和为什么得到了人们的重视 1.规格化设计的大致发展历史 规格化设计,又称契约式设计,最早由Bertrand Meyer于1986年提出,出自于<面向对象软件构 ...

  6. 007-迅雷定时重启AutoHotkey脚本-20190411

    ;; 定时重启迅雷.ahk,;;~ 2019年04月11日;#SingleInstance,forceSetWorkingDir,%A_ScriptDir%DetectHiddenWindows,On ...

  7. 2017湘潭大学邀请赛G题(贪心+优先队列)

    参考博客:http://www.cnblogs.com/chendl111/p/6891770.html 题目链接:https://www.icpc.camp/contests/4mYguiUR8k0 ...

  8. python中变量、函数、类名、模块名等命名方式

    摘要:模块名:小写字母,单词之间用_分割ad_stats.py包名:和模块名一样类名:单词首字母大写AdStatsConfigUtil全局变量名(类变量,在java中相当于static变量):大写字母 ...

  9. 远程调用HBase出错,尝试10次后,报org.apache.hadoop.hbase.MasterNotRunningException错误

    网上的解决方案挺多的,但都不适用于我今天下午碰到的情况. 环 境:HBase-0.90.3在debian 6下,客户端在windows上.我用之前的HBase服务器是没问题的,但重新解压并配置后就有问 ...

  10. 现代程序设计 homework-10

    经过大半学期的学习和练习, 我们把学到的东西综合起来. 通过<现代程序设计>这门课,自己的确学到了好多东西.其实并不是说讲课有多棒,一是因为讲课的次数其实并不多,二是讲课的内容其实感觉并没 ...