链接:https://ac.nowcoder.com/acm/contest/908/G

题意:

A palindrome is a symmetrical string, that is, a string read identically from left to right as well as from right to left. For example, ”a”、”aba”、“abba” are palindrome and “abc”、”aabb” are not.

Let’s define a new function f(s).

For some string s, f(s) is the length of the longest palindrome substring.

    Now you should decide for the given string s, whether f(s) is great than 1.
    The string s only contains lowercase letters.

思路:

找类似aa, aba这种的回文串就行了

代码:

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
const int MAXN = 3e5 + 10;
const int MOD = 1e9 + 7;
int n, m, k, t; int main()
{
cin >> n;
string s;
cin >> s;
bool flag = false;
for (int i = 1;i < n-1;i++)
{
if (s[i] == s[i-1] || s[i-1] == s[i+1])
{
flag = true;
break;
}
}
if (s[n-1] == s[n-2])
flag = true;
if (flag)
cout << "YES" << endl;
else
cout << "NO" << endl; return 0;
}

  

G.Longest Palindrome Substring的更多相关文章

  1. 5.Longest Palindrome substring

    /* * 5.Longest Palindrome substring * 2016-4-9 by Mingyang 自然而然的想到用dp来做 * 刚开始自己做的时候分的条件太细,两个index相等, ...

  2. [LeetCode] Longest Palindrome Substring 具体分析

    Given a string S, find the longest palindromic substring in S. You may assume that the maximum lengt ...

  3. 【算法】最长回文子串 longest palindrome substring

    对于字符串S, 要找到它最长的回文子串,能想到的最暴力方法,应该是对于每个元素i-th都向左向右对称搜索,最后用一个数组span 记录下相对应元素i-th为中心的回文子串长度. 那么问题来了: 1. ...

  4. LeetCode the longest palindrome substring

    回文检测,参考http://blog.csdn.net/feliciafay/article/details/16984031 使用时间复杂度和空间复杂度相对较低的动态规划法来检测,具体的做法 图一 ...

  5. 最长回文字串 (The longest palindrome substring)

    这两天去学了一下,觉得下面那篇文章写的很好,有例子,比较容易懂,所以转一下. 以下内容来自:hihoCoder: 小Hi和小Ho是一对好朋友,出生在信息化社会的他们对编程产生了莫大的兴趣,他们约定好互 ...

  6. Leetcode: Longest Palindromic Substring && Summary: Palindrome

    Given a string s, find the longest palindromic substring in s. You may assume that the maximum lengt ...

  7. 转载-----Java Longest Palindromic Substring(最长回文字符串)

    转载地址:https://www.cnblogs.com/clnchanpin/p/6880322.html 假设一个字符串从左向右写和从右向左写是一样的,这种字符串就叫做palindromic st ...

  8. leetcode--5 Longest Palindromic Substring

    1. 题目: Given a string S, find the longest palindromic substring in S. You may assume that the maximu ...

  9. Java Longest Palindromic Substring(最长回文字符串)

    假设一个字符串从左向右写和从右向左写是一样的,这种字符串就叫做palindromic string.如aba,或者abba.本题是这种,给定输入一个字符串.要求输出一个子串,使得子串是最长的padro ...

随机推荐

  1. 使用C语言解析URL

    1. [代码]容易写成自己输入URL,这里测试一个例子     #include <stdio.h>#include <stdlib.h>#include <string ...

  2. php设计模式课程---9、桥接模式是什么

    php设计模式课程---9.桥接模式是什么 一.总结 一句话总结: 一个类没干完,另外一个类接着给它干完 实质是类的拼接,也就是用类的组合代替了类的继承,因为类的组合可以有很多种方式,所以桥接就是类的 ...

  3. 企业安全建设之搭建开源SIEM平台(上)

    前言 SIEM(security information and event management),顾名思义就是针对安全信息和事件的管理系统,针对大多数企业是不便宜的安全系统,本文结合作者的经验介绍 ...

  4. Mybatis异常_03_Invalid bound statement (not found)

    一.异常信息 Caused by: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): c ...

  5. install docker

    摘要: 我的环境是:CentOS-7-x86_64-Minimal-1511.iso , 也可参考docker官网文档,来安装, url : https://docs.docker.com/engin ...

  6. codeforces 658A A. Bear and Reverse Radewoosh(水题)

    题目链接: A. Bear and Reverse Radewoosh time limit per test 2 seconds memory limit per test 256 megabyte ...

  7. 网络编程学习笔记-TCP拥塞控制机制

    为了防止网络的拥塞现象,TCP提出了一系列的拥塞控制机制.最初由V. Jacobson在1988年的论文中提出的TCP的拥塞控制由“慢启动(Slow start)”和“拥塞避免(Congestion ...

  8. Wireshark 的使用 —— 过滤器(filter)

    1. 基本 ip 地址: 目的IP:ip.dst==192.168.101.8,源ip:ip.src==1.1.1.1 不区分源和目的:ip.addr == 192.168.101.8: 端口过滤: ...

  9. BZOJ_2259_ [Oibh]新型计算机 _最短路

    Description Tim正在摆弄着他设计的“计算机”,他认为这台计算机原理很独特,因此利用它可以解决许多难题. 但是,有一个难题他却解决不了,是这台计算机的输入问题.新型计算机的输入也很独特,假 ...

  10. AIM Tech Round 4 (Div. 2)

    A题 分析:暴力 #include "iostream" #include "cstdio" #include "cstring" #inc ...