hihocoder 1061.Beautiful String
题目链接: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的更多相关文章
- Codeforces Round #604 (Div. 2) A. Beautiful String
链接: https://codeforces.com/contest/1265/problem/A 题意: A string is called beautiful if no two consecu ...
- hiho一下:Beautiful String
hiho一下:Beautiful String 记不清这是 hiho一下第几周的题目了,题目不难,不过对于练习编程,训练思维很有帮助.况且当时笔者处于学习算法的早期, 所以也希望刚接触算法的同学能多去 ...
- CF1328B K-th Beautiful String
CF1328B K-th Beautiful String,然而CF今天却上不去了,这是洛谷的链接 题意 一个长度为\(n\)的字符串,有2个\(\texttt{b}\)和\(n-2\)个\(\tex ...
- hihoCoder 1596 : Beautiful Sequence
Description Consider a positive integer sequence a[1], ..., a[n] (n ≥ 3). If for every 2 ≤ i ≤ n-1, ...
- Codeforces Round #604 (Div. 2) A. Beautiful String(贪心)
题目链接:https://codeforces.com/contest/1265/problem/A 题意 给出一个由 a, b, c, ? 组成的字符串,将 ? 替换为 a, b, c 中的一个字母 ...
- HackerRank beautiful string
问题 https://vjudge.net/problem/HackerRank-beautiful-string 给一个字符串S,可以任意取走S中的两个字符从而得到另外一个字符串P,求有多少种不同的 ...
- B. Pasha and String
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- 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/ ...
- Pasha and String(思维,技巧)
Pasha and String Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u S ...
随机推荐
- MySQL创建一个用户,指定一个数据库 授权
Mysql 创建一个用户 hail,密码 hail,指定一个数据库 haildb 给 hail mysql -u root -ppassworduse mysql;insert into user(h ...
- acdream1233 Royal Federation (构造?)
http://acdream.info/problem?pid=1233 Andrew Stankevich's Contest (3) ASC 3 Royal Federation Special ...
- CF451C Predict Outcome of the Game 水题
Codeforces Round #258 (Div. 2) Predict Outcome of the Game C. Predict Outcome of the Game time limit ...
- php/js获取客户端mac地址的实现代码
这篇文章主要介绍了如何在php与js中分别获取客户度mac地址的方法,需要的朋友可以参考下 废话不多讲,直接上代码吧! 复制代码 代码如下: <?php class MacAddr { ...
- (1)apply族函数总论
来自为知笔记(Wiz) 附件列表
- 定时任务-在spring中配置quartz
使用的版本Spring4.04+Quartz2.2.3,关于jar包自行下载. 详细需要以下几个步骤来完成: 1. 定义要执行的Job类 2. 定义quartz的配置文件applicationCo ...
- 跨Controllers传数据
今天遇到两个问题,第一个是跨controller传值,后一个是比较简单的linq数据库查询问题.先描述以下问题我有一个入库单和一个入库明细,入库的逻辑是先填写入库单在填入库明细.两者要么同时完成,要么 ...
- Android文本读写
//写文件操作 public void writeFileData(String fileName, String message){ try{ FileOut ...
- 如何让网页在浏览器标题栏显示自己制作的图标ico
第一步,制作一个尺寸16x16大小的PNG图片,可以用photoshop等图片处理工具来设计,然后保存到本地电脑上,通过ico在线制作或使用IconWorkshop工具制作ICO图标,ico图标命名为 ...
- Merge k Sorted Lists Leetcode Java
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 使 ...