Codeforces Round #436 (Div. 2) B. Polycarp and Letters
http://codeforces.com/contest/864/problem/B
题意:
给出一个字符串,要求找到一个集合S,使得从S中选出的所有数,在这些数的位置上的字母全部为小写且是不同的字母,并且任意在S中两个数i,j,对于i < j,从i到j的所有位置上都为小写字母。
思路:
找出所有的大写字母的位置,在任意两个“相邻”(指的是这两个大写字母的中间不存在大写字母)的大写字母中寻找S,这样就可以保证全部为小写字母,用set保存出现过的字母就可以了。
代码:
#include <stdio.h>
#include <algorithm>
#include <set>
using namespace std; int pos[];
char a[]; set<int> s;
set<char> c; int main()
{
int n; scanf("%d",&n); scanf("%s",a); pos[] = -;
int cnt = ; for (int i = ;i < n;i++)
{
if (a[i] >= 'A' && a[i] <= 'Z')
{
pos[cnt++] = i;
}
} pos[cnt] = n; int ans = ; for (int i = ;i < cnt;i++)
{
c.clear();s.clear(); int st = pos[i]+,en = pos[i+] - ; for (int j = st;j <= en;j++)
{
if (c.find(a[j]) == c.end())
{
c.insert(a[j]);
s.insert(j);
}
} ans = max((int)s.size(),ans);
} printf("%d\n",ans); return ;
}
Codeforces Round #436 (Div. 2) B. Polycarp and Letters的更多相关文章
- Codeforces Round #436 (Div. 2)【A、B、C、D、E】
Codeforces Round #436 (Div. 2) 敲出一身冷汗...感觉自己宛如智障:( codeforces 864 A. Fair Game[水] 题意:已知n为偶数,有n张卡片,每张 ...
- Codeforces Round #436 (Div. 2) A,B,D
A. Fair Game 题目链接:http://codeforces.com/contest/864/problem/A 水题 #include<iostream> #include&l ...
- Codeforces Round #436 (Div. 2) 题解864A 864B 864C 864D 864E 864F
A. Fair Game time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- Codeforces Round #346 (Div. 2) F. Polycarp and Hay 并查集 bfs
F. Polycarp and Hay 题目连接: http://www.codeforces.com/contest/659/problem/F Description The farmer Pol ...
- Codeforces Round #375 (Div. 2) C. Polycarp at the Radio 贪心
C. Polycarp at the Radio time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- Codeforces Round #346 (Div. 2) F. Polycarp and Hay 并查集
题目链接: 题目 F. Polycarp and Hay time limit per test: 4 seconds memory limit per test: 512 megabytes inp ...
- Codeforces Round #436 (Div. 2) C. Bus
http://codeforces.com/contest/864/problem/C 题意: 坐标轴上有x = 0和 x = a两点,汽车从0到a之后掉头返回,从a到0之后又掉头驶向a...从0到a ...
- Codeforces Round #436 (Div. 2) E. Fire
http://codeforces.com/contest/864/problem/E 题意: 有一堆物品,每个物品有3个属性,需要的时间,失效的时间(一开始)和价值.只能一件一件的选择物品(即在选择 ...
- Codeforces Round #436 (Div. 2)
http://codeforces.com/contest/864 第一次打cf的月赛-- A 题意:给你一个数列,问你能不能保证里面只有两种数且个数相等.2<=n<=100,1<= ...
随机推荐
- vue单页页面开发教程及注意事项
如下图: 1.安装node.js webpack node -v 查看版本 webpack -v 2.安装脚手架 vue-cli npm install -g vue-cli 3. 在项目文件夹创 ...
- Python基础-week02
本节内容摘要:http://www.cnblogs.com/Jame-mei 0.xmind8破解及安装(想要破解版及资料请下方留言,这里不做具体说明) 1.模块初识 2.pyc是什么? 3.pyth ...
- C++模板类与Qt信号槽混用
一.正文 目前正在做一个视频处理相关的项目.项目的技术栈是这样的,UI层采用Qt来实现基本的数据展示和交互,底层音视频采用的是一套基于FFmpeg的视频处理框架.这是一套类似Microsoft Med ...
- TypeScript入门(二)函数新特性
一.TypeScript-Rest and Spread操作符 用来声明任意数量的方法参数 ...args中的...就是Rest and Spread操作符. 例1: 声明一个可以传任意数量的参数进 ...
- 彻底弄懂CommonJS和AMD/CMD!
JS中的模块规范(CommonJS,AMD,CMD),如果你听过js模块化这个东西,那么你就应该听过或CommonJS或AMD甚至是CMD这些规范咯,我也听过,但之前也真的是听听而已. 现在就看看吧, ...
- 00_Linux介绍_我的Linux之路
原文章发布于特克斯博客www.susmote.com 什么是操作系统 操作系统(Operating System,简称OS)是管理和控制计算机硬件与软件资源的计算机程序,是直接运行在"裸机& ...
- [BZOJ 1040][ZJOI2008]骑士
1040: [ZJOI2008]骑士 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 5403 Solved: 2060[Submit][Status ...
- 冲刺NO.2
Alpha冲刺第二天 站立式会议 项目进展 团队成员在确定了所需技术之后,开始学习相关技术的使用,其中包括了HTML5,CSS与SSH框架等开发技术.并且在项目分工配合加以总结和完善,对现有发现的关于 ...
- python 继承基础
class annamal: def chi(self): print(self.name + '吃') def he(self): print(self.name + '喝') class dog( ...
- 201421123042 《Java程序设计》第6周学习总结
1. 本周学习总结 1.1 面向对象学习暂告一段落,请使用思维导图,以封装.继承.多态为核心概念画一张思维导图或相关笔记,对面向对象思想进行一个总结. 注1:关键词与内容不求多,但概念之间的联系要清晰 ...