题目链接:http://hihocoder.com/problemset/problem/1061

题目意思:给出一个不超过10MB长度的字符串,判断是否里面含有一个beautiful strings的子串:连续递增且数量相等的字母。

  照着题目分析翻译的代码。。。

  分析得很到位呢,大赞 ^_^

  http://hihocoder.com/discuss/question/2083

  hiho的题目其实挺好的,有专题,有分析,有代码 & 思路参考。。。

  想想出来工作那么久,浮躁的心啊,一个多快两个月没碰啦,得捡回来呢~~~继续ACM哇,为T-shirt fighting !

  

 #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std; const int maxn = **; // 10MB的字节(1024字节=1KB,1024K=1M)
char str[maxn], s[maxn];
int cnt[maxn]; int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif // ONLINE_JUDGE int n, cas;
while (scanf("%d", &cas) != EOF) {
while (cas--) {
scanf("%d", &n);
scanf("%s", str);
memset(cnt, , sizeof(cnt));
int num = ;
int c = ;
for (int i = ; i < n; i++) {
if (str[i] == str[i+]) {
c++;
}
else {
s[num] = str[i];
cnt[num++] = c;
c = ;
}
} bool flag = false;
for (int i = ; i < num; i++) {
if (s[i-]+ == s[i] && s[i]+ == s[i+] && cnt[i-] >= cnt[i] && cnt[i] <= cnt[i+]) {
flag = true;
break;
}
}
printf("%s\n", flag ? "YES" : "NO");
}
}
return ;
}

  

hihocoder 1061.Beautiful String的更多相关文章

  1. Codeforces Round #604 (Div. 2) A. Beautiful String

    链接: https://codeforces.com/contest/1265/problem/A 题意: A string is called beautiful if no two consecu ...

  2. hiho一下:Beautiful String

    hiho一下:Beautiful String 记不清这是 hiho一下第几周的题目了,题目不难,不过对于练习编程,训练思维很有帮助.况且当时笔者处于学习算法的早期, 所以也希望刚接触算法的同学能多去 ...

  3. CF1328B K-th Beautiful String

    CF1328B K-th Beautiful String,然而CF今天却上不去了,这是洛谷的链接 题意 一个长度为\(n\)的字符串,有2个\(\texttt{b}\)和\(n-2\)个\(\tex ...

  4. hihoCoder 1596 : Beautiful Sequence

    Description Consider a positive integer sequence a[1], ..., a[n] (n ≥ 3). If for every 2 ≤ i ≤ n-1, ...

  5. Codeforces Round #604 (Div. 2) A. Beautiful String(贪心)

    题目链接:https://codeforces.com/contest/1265/problem/A 题意 给出一个由 a, b, c, ? 组成的字符串,将 ? 替换为 a, b, c 中的一个字母 ...

  6. HackerRank beautiful string

    问题 https://vjudge.net/problem/HackerRank-beautiful-string 给一个字符串S,可以任意取走S中的两个字符从而得到另外一个字符串P,求有多少种不同的 ...

  7. B. Pasha and String

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  8. UESTC_Ferris Wheel String 2015 UESTC Training for Search Algorithm & String<Problem L>

    L - Ferris Wheel String Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 43000/43000KB (Java/ ...

  9. Pasha and String(思维,技巧)

    Pasha and String Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u S ...

随机推荐

  1. 从Google开源RE2库学习到的C++测试方案

    最近因为科研需求,一直在研究Google的开源RE2库(正则表达式识别库),库源码体积庞大,用C++写的,对于我这个以前专供Java的人来说真的是一件很痛苦的事,每天只能啃一点点.今天研究了下里面用到 ...

  2. 清北暑假模拟day1 爱

    /* 水题 */ #include<iostream> #include<cstdio> #include<string> #include<cstring& ...

  3. Spark之集群搭建

    注意,这种安装方式是集群方式:然后有常用两种运行模式: standalone , on yarn 区别就是在编写 standalone 与 onyarn 的程序时的配置不一样,具体请参照spar2中的 ...

  4. xcode7 NSAppTransportSecurity

    在Info.plist中添加  NSAppTransportSecurity 类型  Dictionary Dictionary 下添加  NSAllowsArbitraryLoads 类型 Bool ...

  5. springmvc之图片上传

    1.接收到的是图片的流时 //上传头像 @RequestMapping(value = "/uploadHeadSculpture", method = RequestMethod ...

  6. 如何在CentOS 7上安装EPEL源

    EPEL 是什么? EPEL (Extra Packages for Enterprise Linux,企业版Linux的额外软件包) 是Fedora小组维护的一个软件仓库项目,为RHEL/CentO ...

  7. 开关WIFI脚本

    title wifi管理color A@echo on@echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~@echo 1.启用并设定虚拟WiFi网卡;@echo 2.开启无线网络; ...

  8. Eclipse的link方式安装JBPM6插件(JBPM学习之一)

    1. 首先下载最新的JAVA开发最受欢迎的Eclipse IDE工具,下载地址:http://www.eclipse.org/downloads/ 2. 然后去JBPM社区去下载最新的JBPM6,下载 ...

  9. JavaScript 与函数式编程

    原文:https://bethallchurch.github.io/JavaScript-and-Functional-Programming/ 译文:http://www.zcfy.cc/arti ...

  10. PHPExcel类的使用讲解

    下面是总结的几个使用方法 include 'PHPExcel.php'; include 'PHPExcel/Writer/Excel2007.php'; //或者include 'PHPExcel/ ...