Description

Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string s consisting only of lowercase and uppercase Latin letters.

Let A be a set of positions in the string. Let's call it pretty if following conditions are met:

  • letters on positions from A in the string are all distinct and lowercase;
  • there are no uppercase letters in the string which are situated between positions from A (i.e. there is no such j that s[j] is an uppercase letter, and a1 < j < a2 for some a1 and a2 from A).

Write a program that will determine the maximum number of elements in a pretty set of positions.

Input

The first line contains a single integer n (1 ≤ n ≤ 200) — length of string s.

The second line contains a string s consisting of lowercase and uppercase Latin letters.

Output

Print maximum number of elements in pretty set of positions for string s.

Sample Input

  1. 11aaaaBaabAbA

Sample Output

  1. 2

HINT

In the first example the desired positions might be 6 and 8 or 7 and 8. Positions 6 and 7 contain letters 'a', position 8 contains letter 'b'. The pair of positions 1 and 8 is not suitable because there is an uppercase letter 'B' between these position.

题解

在一个字符串中找一段,使其中没有大写字母,并且小写字母种数最多。

考虑$n<=200$,直接暴力枚举。

I think there is no need to tell you how to solve this problem...

  1. //It is made by Awson on 2017.9.29
  2. #include <set>
  3. #include <map>
  4. #include <cmath>
  5. #include <ctime>
  6. #include <queue>
  7. #include <stack>
  8. #include <vector>
  9. #include <cstdio>
  10. #include <string>
  11. #include <cstring>
  12. #include <cstdlib>
  13. #include <iostream>
  14. #include <algorithm>
  15. #define LL long long
  16. #define Max(a, b) ((a) > (b) ? (a) : (b))
  17. #define Min(a, b) ((a) < (b) ? (a) : (b))
  18. #define sqr(x) ((x)*(x))
  19. #define lowbit(x) ((x)&(-(x)))
  20. using namespace std;
  21. void read(int &x) {
  22. ;
  23. ); ch = getchar());
  24. ; isdigit(ch); x = (x<<)+(x<<)+ch-, ch = getchar());
  25. x *= -*flag;
  26. }
  27.  
  28. int n, ans;
  29. ];
  30. ];
  31.  
  32. void work() {
  33. read(n);
  34. ; i <= n; i++)
  35. cin>>ch[i];
  36. ; i <= n; i++)
  37. for (int j = i; j <= n; j++) {
  38. memset(judge, , sizeof(judge));
  39. ;
  40. for (int k = i; k <= j; k++)
  41. if (ch[k] >= 'A' && ch[k] <= 'Z') {
  42. flag = ;
  43. break;
  44. }
  45. ;
  46. if (flag) continue;
  47. ;
  48. ; k < ; k++)
  49. cnt += judge[k];
  50. ans = Max(ans, cnt);
  51. }
  52. printf("%d\n", ans);
  53. }
  54. int main() {
  55. work();
  56. ;
  57. }

[Codeforces 864B]Polycarp and Letters的更多相关文章

  1. Codeforce B. Polycarp and Letters

    B. Polycarp and Letters time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  2. Codeforces 659F Polycarp and Hay 并查集

    链接 Codeforces 659F Polycarp and Hay 题意 一个矩阵,减小一些数字的大小使得构成一个连通块的和恰好等于k,要求连通块中至少保持一个不变 思路 将数值从小到大排序,按顺 ...

  3. Codeforces Round #436 (Div. 2) B. Polycarp and Letters

    http://codeforces.com/contest/864/problem/B 题意: 给出一个字符串,要求找到一个集合S,使得从S中选出的所有数,在这些数的位置上的字母全部为小写且是不同的字 ...

  4. Codeforces Round #436 B. Polycarp and Letters

    题意:给你一串长度为n的字符,由大小写字母组成,求连续的小写子串中不同字母个数的最大值. Input 11aaaaBaabAbA Output 2 Input 12zACaAbbaazzC Outpu ...

  5. Codeforces 723C. Polycarp at the Radio 模拟

    C. Polycarp at the Radio time limit per test: 2 seconds memory limit per test: 256 megabytes input: ...

  6. Polycarp and Letters(set首战!)

    Description Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string s con ...

  7. codeforces 727F. Polycarp's problems

    题目链接:http://codeforces.com/contest/727/problem/F 题目大意:有n个问题,每个问题有一个价值ai,一开始的心情值为q,每当读到一个问题时,心情值将会加上该 ...

  8. codeforces 723C : Polycarp at the Radio

    Description Polycarp is a music editor at the radio station. He received a playlist for tomorrow, th ...

  9. Codeforces Round #452 F. Letters Removing

    Description Petya has a string of length n consisting of small and large English letters and digits. ...

随机推荐

  1. 学号:201621123032 《Java程序设计》第12周学习总结

    1:本周学习总结 1.1:以你喜欢的方式(思维导图或其他)归纳总结多流与文件相关内容. 2:面向系统综合设计-图书馆管理系统或购物车 2.1: 简述如何使用流与文件改造你的系统.文件中数据的格式如何? ...

  2. 项目Beta冲刺Day6

    项目进展 李明皇 今天解决的进度 进行前后端联动调试 明天安排 完善程序运行逻辑 林翔 今天解决的进度 服务器端发布消息,删除消息,检索消息,个人发布的action 明天安排 图片功能遇到问题,微信小 ...

  3. 《高级软件测试》JIRA使用手册(二)JIRA安装

    Jira Software 下载地址 Windows系统x86平台:https://downloads.atlassian.com/software/jira/downloads/atlassian- ...

  4. nyoj 苹果

    苹果 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 ctest有n个苹果,要将它放入容量为v的背包.给出第i个苹果的大小和价钱,求出能放入背包的苹果的总价钱最大值. ...

  5. Centos7 Yum方式安装Mysql7

    不废话,直奔主题,可以覆盖安装. 下载并安装MySQL官方的 Yum Repository [root@localhost ~]# wget -i -c http://dev.mysql.com/ge ...

  6. 算法题丨3Sum Closest

    描述 Given an array S of n integers, find three integers in S such that the sum is closest to a given ...

  7. print 函数设置字体颜色

    格式:\033[显示方式;前景色;背景色m数值表示的参数含义:显示方式: 0(默认值).1(高亮).22(非粗体).4(下划线).24(非下划线). 5(闪烁).25(非闪烁).7(反显).27(非反 ...

  8. wordpress | WP Mail SMTP使用QQ邮箱发布失败的解决办法

    在使用contact form 7插件时遇到邮件发送失败的问题,经过检查发现是因为服务器不支持mail()函数,判断是否支持mail()函数可以参考http://www.diyzhan.com/201 ...

  9. Spring Cloud的DataRest(二)

    一.创建工程 1.主程序 2.依赖 3.配置 二.案例开发 1.entity 2.repository 三.案例验证 安装postman4.13,启动应用,执行如下案例验证! 1.create - p ...

  10. bootstrap 一个简单的登陆页面

    效果如图:用bootstrap 写的一个简单的登陆 一.修改样式 样式可以自己调整,例如换个背景色之类的,修改 background-color属性就可以 #from { background-col ...