题目链接: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. requests的安装与简单运用

    requests是python的一个HTTP客户端库,跟urllib,urllib2类似,那为什么要用requests而不用urllib2呢?官方文档中是这样说明的: python的标准库urllib ...

  2. R中的name命名系列函数总结

    本文原创,转载请注明出处,本人Q1273314690 R中关于给行列赋名称的函数有 dimnames,names,rowname,colname,row.names 这五个函数,初学的时候往往分不清楚 ...

  3. PHP安装laravel(win+linux)

    作为一名不优秀的程序猿,忙碌的四月终于结束了,五一大假的最后一天,终于有时间来整理整理这段时间的收获了. 一.laravel介绍 首先看看http://www.sitepoint.com/网站做的一个 ...

  4. 大数据处理时用到maven的repository

    由于做数据处理时,经常遇到maven 下载依赖包错误,下面我将自己下载好的repository 分享下 里边包含:Hadoop ,storm ,sprk ,kafka ,等 压缩后500多M. htt ...

  5. ajax 请求多张图片数据

    需求分析: 实现对网页上的图片进行显示.由于读取图片名称相同,而图片内容已发生改变.采用网上所用的要求浏览器不缓存的操作不生效 <META http-equiv="Pragma&quo ...

  6. C#操作word模板插入文字、图片及表格详细步骤

    c#操作word模板插入文字.图片及表格 1.建立word模板文件 person.dot用书签 标示相关字段的填充位置 2.建立web应用程序 加入Microsoft.Office.Interop.W ...

  7. CMake Error: your CXX compiler: "" was not found

    [root@amax src]# cmake . -- The CXX compiler identification is unknown CMake Error at /usr/local/sha ...

  8. Entity Framework Code First数据库自动更新2

    以前做项目的时候,没有采用分类库的形式,所以迁移一致非常顺利,没有出现过任何状况. 这次做项目稍微有点大,必须要分类库才方便开发维护. 在解决方案中启用项目EntityFramework迁移时却发生了 ...

  9. 关于js css html加载顺序整理

    1.js放在head中会立即执行,阻塞后续的资源下载与执行.因为js有可能会修改dom,如果不阻塞后续的资源下载,dom的操作顺序不可控. 正常的网页加载流程是这样的. 浏览器一边下载HTML网页,一 ...

  10. 观察者(Observer)模式

    http://www.cnblogs.com/zhenyulu/articles/73723.html 一. 观察者(Observer)模式 观察者模式又叫做发布-订阅(Publish/Subscri ...