A. Grasshopper And the String(CF ROUND 378 DIV2)
A. Grasshopper And the String
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far end of the string, jumping only on vowels of the English alphabet. Jump ability is the maximum possible length of his jump.
Formally, consider that at the begginning the Grasshopper is located directly in front of the leftmost character of the string. His goal is to reach the position right after the rightmost character of the string. In one jump the Grasshopper could jump to the right any distance from 1 to the value of his jump ability.
The picture corresponds to the first example.
The following letters are vowels: 'A', 'E', 'I', 'O', 'U' and 'Y'.
Input
The first line contains non-empty string consisting of capital English letters. It is guaranteed that the length of the string does not exceed 100.
Output
Print single integer a — the minimum jump ability of the Grasshopper (in the number of symbols) that is needed to overcome the given string, jumping only on vowels.
Examples
Input
ABABBBACFEYUKOTT
Output
4
Input
AAA
Output
1
题目链接:http://codeforces.com/contest/733/problem/A
题目本意是让求他最大跳跃距离(最大跳跃距离是两个元音字母直接的距离,最后一个元音字母和结尾的距离,还有一种可能就是" B " 这样的情况)
WA了两发,
第一发没考虑到:
A 这样的数据
第二发没考虑到
B 这样的数据
AC代码:
#include<cstdio> #include<iostream> #include<cmath> #include<algorithm> #include<cstring> using namespace std; bool vowel( char i ) { if(i == 'A' || i == 'E' || i== 'I' || i== 'O' || i== 'U' || i == 'Y' || i=='\0' ||i==' ' ) returntrue ; returnfalse ; } int main() { strings; cin>>s; s='' + s ; int_length = s.length() ; intmax = 1 ; for(int i = 0 ; i < _length ; i++) { if(vowel( s[i] ) ) { for(int j = i+1; j<=_length ; j++) { if(vowel( s[j] ) ) { if(j - i > max ) max= j-i; break; } } } } cout<< max << endl ; return0 ; }
A. Grasshopper And the String(CF ROUND 378 DIV2)的更多相关文章
- CF Round #580(div2)题解报告
CF Round #580(div2)题解报告 T1 T2 水题,不管 T3 构造题,证明大约感性理解一下 我们想既然存在解 \(|a[n + i] - a[i]| = 1\) 这是必须要满足的 既然 ...
- CF round #622 (div2)
CF Round 622 div2 A.简单模拟 B.数学 题意: 某人A参加一个比赛,共n人参加,有两轮,给定这两轮的名次x,y,总排名记为两轮排名和x+y,此值越小名次越前,并且对于与A同分者而言 ...
- [CF Round #295 div2] C. DNA Alignment 【观察与思考0.0】
题目链接:C. DNA Alignment 题目大意就不写了,因为叙述会比较麻烦..还是直接看英文题面吧. 题目分析 经过观察与思考,可以发现,构造的串 T 的每一个字符都与给定串 S 的每一个字符匹 ...
- [CF Round #294 div2] E. A and B and Lecture Rooms 【树上倍增】
题目链接:E. A and B and Lecture Rooms 题目大意 给定一颗节点数10^5的树,有10^5个询问,每次询问树上到xi, yi这两个点距离相等的点有多少个. 题目分析 若 x= ...
- [CF Round #294 div2] D. A and B and Interesting Substrings 【Map】
题目链接:D. A and B and Interesting Substrings 题目大意 给定26个小写字母的权值,一共26个整数(有正有负). 给定一个小写字母组成的字符串(长度10^5),求 ...
- A. Alyona and Numbers(CF ROUND 358 DIV2)
A. Alyona and Numbers time limit per test 1 second memory limit per test 256 megabytes input standar ...
- CF Round#436 div2
额,这次的题目其实挺智障的.所以通过这次比赛,我也发现了自己是一个智障.... 不说太多,说多是泪... A. Fair Game 题意:给你一个数组,看你能否把它均分为两个所有元素均相同的子数组. ...
- CF Round #569 Div2(contest1180)
比赛链接:http://codeforces.com/contest/1180 Problem A 题意:给出n,问方块数.看图理解... Solution: 找一找规律就可以了,发现方块数为2n*( ...
- CF Round #687 Div2 简要题解
题面 A 可以发现,最远的几个人一定是 \((1, 1), (1, m), (n, 1), (n, m)\) 中的一个,直接计算即可. B 注意到颜色数量很少,直接暴力枚举最终的颜色后模拟即可. C ...
随机推荐
- “Will not add file alias 'samefile' ('SameFile' already exists in index)” when `git add/commit` operation
从远程仓库pull下来的代码有两个类类名首字母小写出现如下情况 然后我想删了重新写一下(就是把这个类删了,代码复制到名字正确的类里面),然后commit的时候出现这个错误,后来删一个commit一下, ...
- Python中的多进程与多线程(二)
在上一章中,学习了Python多进程编程的一些基本方法:使用跨平台多进程模块multiprocessing提供的Process.Pool.Queue.Lock.Pipe等类,实现子进程创建.进程池(批 ...
- 使用gulp构建自动化工作流
简单易用 高效构建 高质量的生态圈 可能很多人会说现在提gulp也太落后了吧,但我想说写点东西并不是为了讨论它是否过时,而是来帮助我们自己来记忆.整理和学习.任何工具,我需要,我才去使用它,正如此时我 ...
- elasticsearch基本概念
NRT(近实时搜索) Elasticsearch是一个NRT平台.这意味着当你索引一个文件时,在细微的延迟(通常1s)之后,该文件才能被搜索到. Cluster(集群) cluster是在所有节点中保 ...
- 读取Oracle表结构数据
<html lang="zh-cn"> <head> <meta name="generator" content="O ...
- SDN基础
http://www.h3c.com.cn/Solution/Smart_Network/SDN/ http://network.51cto.com/network/content2013/SDNke ...
- mysql 查看数据库中所有表的记录数
use information_schema; SELECT DISTINCT t.table_name, t.engine '表引擎', t.table_rowsFROM TABLES tWHERE ...
- find用法积累
查找目录下的所有文件中是否含有某个字符串 find .|xargs grep -ri "IBM" 查找目录下的所有文件中是否含有某个字符串,并且只打印出文件名 find .|xar ...
- tableviewcell 点击 设置
table?.separatorInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) //设置cell 下边线 位置 table?.se ...
- C语言 · 分解质因数
问题描述 求出区间[a,b]中所有整数的质因数分解. 输入格式 输入两个整数a,b. 输出格式 每行输出一个数的分解,形如k=a1*a2*a3...(a1<=a2<=a3...,k也是从小 ...