题意:和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. Git Submodule管理项目子模块

    使用场景 当项目越来越庞大之后,不可避免的要拆分成多个子模块,我们希望各个子模块有独立的版本管理,并且由专门的人去维护,这时候我们就要用到git的submodule功能. 常用命令 git clone ...

  2. 【vue】vue-router路径无法正确跳转

    具体描述:vue项目,npm run build时点击路由切换,第一次点击没问题,再点不会切换报错如下图 原因分析:vue-router配置路由,当代码分割和懒加载时,由于webpack配置不当,导致 ...

  3. TMS-规划图

    规划图 规划图 规划图 规划图 规划图 规划图 规划图 规划图 规划图 规划图 规划图 规划图 规划图 规划图 规划图 规划图 规划图 规划图 规划图 规划图 规划图 规划图 规划图 规划图 规划图 ...

  4. 任务调度工具Quartz入门笔记

    一,导包 1)官网下载:http://www.quartz-scheduler.org/downloads/ 2)Maven <dependency> <groupId>org ...

  5. DSL 系列(2) - 插件的论述与实现

    前言 本文主要探讨基于 DSL(domain specific language) 之上的插件设计,他们是领域的附属,为领域提供额外的服务,但领域不依赖于他们. 1. 论述 领域应当尽可能地去专注他的 ...

  6. python2.x版本与python3.x版本的区别以及运算符

    python2.x中: 重复代码,语言不统一,不支持中文 py2中除法获取的都是整形 py2中有long(长整形) print 可以加括号也可以不加括号 range 在py2中打印的结果是列表 py2 ...

  7. elasticsearch简单操作(二)

    让我们建立一个员工目录,假设我们刚好在Megacorp工作,这时人力资源部门出于某种目的需要让我们创建一个员工目录,这个目录用于促进人文关怀和用于实时协同工作,所以它有以下不同的需求:1.数据能够包含 ...

  8. C语言之运算符、表达式和语句

    #include<stdio.h> #define ADJUST 7.31 int main(void) { const double SCALE = 0.333; double shoe ...

  9. gnuplot画折线图

    之前尝试用jfreechart画自定义横坐标的折线图或时序图,发现很复杂,后来改用gnuplot了. gnuplot在网上一搜就能找到下载地址. 安装完成后,主要是命令行形式的交互界面,至少比jfre ...

  10. 学习WebSocket

    初识WebSocket: index.html <!DOCTYPE html> <html> <head> <meta charset="UTF-8 ...