B. Polycarp and Letters
来源:互联网 发布:半包包括哪些 知乎 编辑:程序博客网 时间:2024/05/22 06:42
解题说明:题意是给定一个长度为n的字符串,求最大的位置集合,每个位置都是小写字母且各不相同,每两个位置之间没有大写字母。可以采用暴力枚举来判断。
#include<cstdio>#include<iostream>#include<string>#include <ctype.h>#include<cstring>using namespace std;int occ[256];int main() {int n,i;int best = 0;int cnt = 0;scanf("%d", &n);getchar();unsigned char c;for (i = 0; i < n; ++i) {scanf("%c", &c);if (isupper(c)) {memset(occ, 0, 256 * 4);if (cnt > best){best = cnt;}cnt = 0;}else {cnt += (1 - occ[c]);occ[c] = 1;}}printf("%d\n", best > cnt ? best : cnt);return 0;}
阅读全文
0 0
- B. Polycarp and Letters
- B. Polycarp and Letters
- CodeForces 864B Polycarp and Letters
- codeforces 864B 之 Polycarp and Letters
- Polycarp and Letters
- Codeforces Round #436 (Div. 2) B. Polycarp and Letters
- Codeforces Round #436 (Div. 2) A.Fair Game B.Polycarp and Letters C. Bus D.Make a Permutation!
- cf443A Anton and Letters
- A. Anton and Letters
- Anton and Letters
- SOJ.Letters and Words
- Codeforces Anton and Letters
- cf434 B. Polycarp's phone book
- Codeforces 659F Polycarp and Hay【BFS】
- 【17.69%】【codeforces 659F】Polycarp and Hay
- sicily 1050.Numbers and Letters
- 443A - Anton and Letters
- LETTERS
- 自定义view原环进度圈
- Redis入门到精通-Redis集群的扩展
- 网易2018校招 重排数列
- 26 记一次 SpringMVC 406 The resource identified by this request is only capable of generating responses
- Linux中VMware虚拟机增加磁盘空间的扩容操作[图文]
- B. Polycarp and Letters
- jvm的永久代
- 今日头条
- 最全的pom.xml中文详解
- 线段树
- AngularJS页面的增删改查
- Java学习心得之接口
- SSH与SSM学习之Spring10——Spring与junit整合测试
- 类似今日头条(侧拉+viewloder+PullToRefreshListView+viewpager无限轮播)