I. Mirrored String II

题目描述

Note: this is a harder version of Mirrored string I.

The gorillas have recently discovered that the image on the surface of the water is actually a reflection of themselves. So, the next thing for them to discover is mirrored strings.

A mirrored string is a palindrome string that will not change if you view it on a mirror.

Examples of mirrored strings are “MOM”, “IOI” or “HUH”. Therefore, mirrored strings must contain only mirrored letters {A, H, I, M, O, T, U, V, W, X, Y} and be a palindrome.

e.g. IWWI, MHHM are mirrored strings, while IWIW, TFC are not.

A palindrome is a string that is read the same forwards and backwards.

Given a string S of length N, help the gorillas by printing the length of the longest mirrored substring that can be made from string S.

A substring is a (possibly empty) string of characters that is contained in another string S. e.g. “Hell” is a substring of “Hello”.

输入

The first line of input is T – the number of test cases.

Each test case contains a non-empty string S of maximum length 1000. The string contains only uppercase English letters.

输出

For each test case, output on a line a single integer - the length of the longest mirrored substring that can be made from string S.

样例

inputCopy
3
IOIKIOOI
ROQ
WOWMAN
outputCopy
4
1
3

题意

字符串处理

AC代码

GYM 101350 I. Mirrored String II相关推荐

  1. GYM 101350 H. Mirrored String I

    题目描述 The gorillas have recently discovered that the image on the surface of the water is actually a ...

  2. Gym - 101350I - Mirrored String II (马拉车)

    题意: 求最长回文子串,但每个字母也必须是回文的 思路: 马拉车,但奇数长度的回文串需要特判 #include <bits/stdc++.h> using namespace std; c ...

  3. Mirrored String I Gym - 101350H (水)判断回文

    https://vjudge.net/contest/159763#problem/H 判断是不是由指定字符组成的回文串 // // main.cpp // 160929 // // Created ...

  4. 定间隔字符翻转(Reverse String II)

    一.学习要点: 1.主要是对剩余字符长度的考虑,大于k的时候,对前k个进行翻转:小于k的时候,对实际个数进行全翻转:本程序中翻转个数用变量x来表示: 二.代码: #include<stdlib. ...

  5. LeetCode之Reverse String II

    1.题目 Given a string and an integer k, you need to reverse the first k characters for every 2k charac ...

  6. 牛客 String II

    文章目录 1. 题目 2. 解题 1. 题目 链接:https://ac.nowcoder.com/acm/contest/9715/B 来源:牛客网 给出一个仅包含小写字母的字符串s,你最多可以操作 ...

  7. LeetCode 541. Reverse String II

    题目: Given a string and an integer k, you need to reverse the first k characters for every 2k charact ...

  8. C#LeetCode刷题之#541-反转字符串 II(Reverse String II)

    问题 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/3951 访问. 给定一个字符串和一个整数 k,你需要对从字符串开头 ...

  9. GYM 101350 G. Snake Rana ( 容斥

    G. Snake Rana 题目描述 Old Macdonald wants to build a new hen house for his hens. He buys a new rectangu ...

最新文章

  1. python公共键_Python利用公共键如何对字典列表进行排序详解
  2. 11G RAC ORA-32701
  3. Teams Bot如何做全球化
  4. 一文带你读懂!华为云在ACMUG技术沙龙上都透露了些啥?
  5. Pose-Aware Face Recognition in the Wild--填坑1
  6. LSI加入多核联盟参与编程与应用标准制定
  7. MySql解决办法:2004:Can't create TCP/IP socket (24)
  8. 企业微信工具栏获取外部联系人unionid
  9. DIY一个正弦表计算器,用于单片机查表生成正弦波
  10. 七 代码检查工具安装
  11. dimm和udimm_服务器内存UDIMM与RDIMM区别
  12. VR全景制作教程,拍摄VR全景图片其实很简单
  13. 用python的requests第三方模块抓取王者荣耀所有英雄的皮肤
  14. 教你画架构图,看一次就会了
  15. RHCE之路https网站搭建,论坛搭建
  16. C++中fstream
  17. 如何压缩图片大小到200k以下?照片太大怎么压缩到200k?
  18. python求素数平均值_用python怎么求素数
  19. IT方面学习交流群推荐
  20. python判断三角形是否直角_Python3如何判断三角形的类型

热门文章

  1. 三维建模软件之比较:和SketchUp、Revit建模软件相媲美 3D 地图 可视化 ThingJS
  2. java对接portal协议_Portal协议分析
  3. 如何自定义您的Nintendo Switch主屏幕
  4. 通达信公式:如何表示5个数据中的前三大数值?
  5. keystore生成签名证书
  6. 最小生成树-普利姆和克鲁斯卡尔算法
  7. 笔记本 亮度 无法调解
  8. 【音视频零基础入门 1】视频播放器原理、流媒体协议、封装格式、视频编码、音频编码
  9. STM32输出PWM波形以及实现LED呼吸灯
  10. matplotlib绘制多子图共享鼠标光标