题目链接: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. 如何运行python

    如何运行Python程序 不少新手朋友遇到的第一个问题,不是Python的数据结构,不是Python的类库使用,更不是第三方模块.框架的应用,而是简单的“如何运行”!Python可用以下三种方式运行, ...

  2. Linux里startup.sh 和 shutdown.sh

    最近用socket编写了一个服务端程序,监听1024端口,检测客户端发来的请求,所在Linux里写启动和停止的脚本: 在Eclipse里java写好程序,右击导出生成 Runnable JAR fil ...

  3. 详细介绍如何在win7下首次实现通过Git bash向Github提交项目

    详细介绍如何在win7下首次实现通过Git bash向Github提交项目 引自:http://jingpin.jikexueyuan.com/article/35944.html 作者: wddoe ...

  4. [译]Mongoose指南 - Population

    MongoDB没有join, 但是有的时候我们需要引用其它collection的documents, 这个时候就需要populate了. 我们可以populate单个document, 多个docum ...

  5. POJ 2155 Matrix

    二维树状数组....                          Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissio ...

  6. 全文检索引擎Solr系列——整合MySQL、MongoDB

    MySQL 拷贝mysql-connector-java-5.1.25-bin.jar到E:\solr-4.8.0\example\solr-webapp\webapp\WEB-INF\lib目录下面 ...

  7. 正则表达式学习笔记(附:Java版示例代码)

    具体学习推荐:正则表达式30分钟入门教程 .         除换行符以外的任意字符\w      word,正常字符,可以当做变量名的,字母.数字.下划线.汉字\s        space,空白符 ...

  8. PHP Socket实现websocket(四)Select函数

    int select(int maxfdp,fd_set *readfds,fd_set *writefds,fd_set *errorfds,struct timeval *timeout); /* ...

  9. Android学习笔记(八)——四种基本布局

    //此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! 布局是一种可用于放置很多控件的容器,它可以按照一定的规律调整内部控件的位置,或是嵌套子布局,从而编写出精美的界 ...

  10. 从输入 URL 到浏览器接收的过程中发生了什么事情?

    从输入 URL 到浏览器接收的过程中发生了什么事情? What really happens when you navigate to a URL 上面两篇文章都解读的很好,值得阅读. 接下来在总结一 ...