hdu2369 Broken Keyboard(类似dfs)
转载请注明出处:http://blog.csdn.net/u012860063
题目链接: pid=2369">http://acm.hdu.edu.cn/showproblem.php? pid=2369
代码例如以下:
#include <cstdio>
#include <cstring>
char s[1100047];
int hash[247];
int main()
{
__int64 n;
while(~scanf("%I64d",&n) && n)
{
getchar();
gets(s);
__int64 len = strlen(s);
memset(hash,0,sizeof(hash));
__int64 i, star = 0, ans = 0, diff = 0;
for(i = 0; i < len; i++)
{
++hash[s[i]];//映射值+1
if(hash[s[i]] == 1)//假设是第一次出现
{
diff++;//不同字母数+1
if(diff > n)//假设超过n个不同字母
{
while(--hash[s[star++]] > 0);//起点向右挪动 直到消去一个字母
diff--;//不同字母数返回正常取值
}
}
int LEN = i-star+1;//获得这个字符串长度
ans = ans > LEN?ans:LEN;//保存最大
}
printf("%I64d\n",ans);
}
return 0;
}
hdu2369 Broken Keyboard(类似dfs)的更多相关文章
- N - Broken Keyboard (a.k.a. Beiju Text)(DFS,链表)
N - Broken Keyboard (a.k.a. Beiju Text) Time Limit:1000MS Memory Limit:0KB 64bit IO Format:% ...
- UVa 11998 Broken Keyboard (数组模拟链表问题)
题目链接: 传送门 Broken Keyboard #include<bits/stdc++.h> using namespace std; char str[100010]; int m ...
- UVa 11988 Broken Keyboard(链表->数组实现)
/*数组形式描述链表:链表不一定要用指针. 题目链接:UVa 11988 Broken Keyboard 题目大意: 小明没有开屏幕输入一个字符串,电脑键盘出现了问题会不定时的录入 home end ...
- 1084. Broken Keyboard (20)
On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters ...
- B - Broken Keyboard (a.k.a. Beiju Text)
Problem B Broken Keyboard (a.k.a. Beiju Text) You're typing a long text with a broken keyboard. Well ...
- uva - Broken Keyboard (a.k.a. Beiju Text)(链表)
11988 - Broken Keyboard (a.k.a. Beiju Text) You’re typing a long text with a broken keyboard. Well i ...
- PAT1084:Broken Keyboard
1084. Broken Keyboard (20) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue On a ...
- PAT 1084 Broken Keyboard
1084 Broken Keyboard (20 分) On a broken keyboard, some of the keys are worn out. So when you type ...
- A1084. Broken Keyboard
On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters ...
随机推荐
- VS2010中使用CL快速 生成DLL的方法
方案一: 1.命令行中输入cl example.cpp,生成example.obj和example.lib文件.有可能还会提示“没有入口点”的错误.这是因为我们的CPP中是要生成dll文件的,并没有m ...
- 【ThinkingInC++】53、构造函数,析构函数,全局变量
/** * 图书:[ThinkingInC++] * 特征:构造函数,析构函数,全局变量 * 时刻:2014年9一个月17日本18:07:43 * 笔者:cutter_point */ #includ ...
- 【Spring】Spring学习笔记-01-入门级实例
听说当前Spring框架很流行,我也准备好好学学Spring开发,并将学习的过程和大家分享,希望能对志同道合的同学有所帮助. 以下是我学习Spring的第一个样例. 1.Spring开发环境的搭建 我 ...
- 安装github for windows问题解决
到官网下载windows环境下的github,在安装时出现下面问题 An error occurred trying to download 'http://github-windows.s3.ama ...
- HDU 1874 畅通公程续 (最短路 水)
Problem Description 某省自从实行了非常多年的畅通project计划后,最终修建了非常多路.只是路多了也不好,每次要从一个城镇到还有一个城镇时,都有很多种道路方案能够选择,而某些方案 ...
- 在 VS 类库项目中 Add Service References 和 Add Web References 的区别
原文:在 VS 类库项目中 Add Service References 和 Add Web References 的区别 出身问题: 1.在vs2005时代,Add Web Reference(添加 ...
- SRM 590 DIV1
转载请注明出处,谢谢viewmode=contents">http://blog.csdn.net/ACM_cxlove?viewmode=contents by---cxlov ...
- cocos2d-x -- 渠道SDK【棱镜】接入(1)
棱镜SDK简单介绍 若想让游戏上线,渠道接入步骤是不可缺少的,为了避免一对一接入渠道问题,我选择了棱镜SDK,由于棱镜是游戏与渠道SDK的中间层,为CP厂商屏蔽各个渠道SDK之间的差异,整个接入过程, ...
- Android引入高速缓存的异步加载全分辨率
Android引进高速缓存的异步加载全分辨率 为什么要缓存 通过图像缩放,我们这样做是对的异步加载优化的大图,但现在的App这不仅是一款高清大图.图.动不动就是图文混排.以图代文,假设这些图片都载入到 ...
- 原生js判断css3动画过度(transition)结束 transitionend事件 以及关键帧keyframes动画结束(animation)回调函数 animationEnd 以及 css 过渡 transition无效
上图的 demo 主要讲的 是 css transition的过渡回调函数transitionend事件: css3 的时代,css3--动画 一切皆有可能: 传统的js 可以通过回调函数判断动画 ...