time limit per test1 second

memory limit per test256 megabytes

inputstandard input

outputstandard 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

【题解】



最大长度就是这个字符串的长度;

枚举一下最大跳跃距离就好;

100的距离

怎么样也不会超时了;

随便写吧;

#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <stack>
#include <string>
#define lson L,m,rt<<1
#define rson m+1,R,rt<<1|1
#define LL long long using namespace std; const int MAXN = 2000;
const int dx[5] = {0,1,-1,0,0};
const int dy[5] = {0,0,0,-1,1};
const double pi = acos(-1.0); string s1;
bool can[MAXN]; void input_LL(LL &r)
{
r = 0;
char t = getchar();
while (!isdigit(t) && t!='-') t = getchar();
LL sign = 1;
if (t == '-')sign = -1;
while (!isdigit(t)) t = getchar();
while (isdigit(t)) r = r * 10 + t - '0', t = getchar();
r = r*sign;
} void input_int(int &r)
{
r = 0;
char t = getchar();
while (!isdigit(t)&&t!='-') t = getchar();
int sign = 1;
if (t == '-')sign = -1;
while (!isdigit(t)) t = getchar();
while (isdigit(t)) r = r * 10 + t - '0', t = getchar();
r = r*sign;
} int main()
{
//freopen("F:\\rush.txt","r",stdin);
cin >> s1;
int len = s1.size();
for (int i = 1;i <= len;i++)
if (s1[i-1]=='A' || s1[i-1]=='E' || s1[i-1]=='I' || s1[i-1] == 'O' || s1[i-1]=='U' || s1[i-1]=='Y')
can[i] = true;
for (int i = len+1;i<= len*3;i++)
can[i] = true;
for (int k = 1;k<=len+1;k++)
{
int now = 0;
while (true)
{
bool judge = false;
for (int j = now+k;j>=now+1;j--)
if (can[j])
{
now = j;
judge = true;
break;
}
if (!judge) break;
if (now > len)
{
printf("%d\n",k);
return 0;
}
}
}
return 0;
}

【非常高%】【codeforces 733A】Grasshopper And the String的更多相关文章

  1. 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 ...

  2. codeforces ~ 1009 B Minimum Ternary String(超级恶心的思维题

    http://codeforces.com/problemset/problem/1009/B B. Minimum Ternary String time limit per test 1 seco ...

  3. 【codeforces 709D】Recover the String

    [题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...

  4. Codeforces Round #617 (Div. 3) String Coloring(E1.E2)

    (easy version): 题目链接:http://codeforces.com/contest/1296/problem/E1 题目一句话就是说,两种颜色不同的字符可以相互换位, 问,对这字符串 ...

  5. codeforces 709D D. Recover the String(构造)

    题目链接: D. Recover the String time limit per test 1 second memory limit per test 256 megabytes input s ...

  6. codeforces 710E E. Generate a String(dp)

    题目链接: E. Generate a String time limit per test 2 seconds memory limit per test 512 megabytes input s ...

  7. Codeforces 710 E. Generate a String (dp)

    题目链接:http://codeforces.com/problemset/problem/710/E 加或者减一个字符代价为x,字符数量翻倍代价为y,初始空字符,问你到n个字符的最小代价是多少. d ...

  8. codeforces 676C C. Vasya and String(二分)

    题目链接: C. Vasya and String time limit per test 1 second memory limit per test 256 megabytes input sta ...

  9. codeforces 598B Queries on a String

    题目链接:http://codeforces.com/problemset/problem/598/B 题目分类:字符串 题意:给定一个串,然后n次旋转,每次给l,r,k,表示区间l到r的字符进行k次 ...

随机推荐

  1. decode与case when

    语法 decode(条件,值1,返回值1,值2,返回值2,...值n,返回值n,缺省值) select * from reglike; ,),'aaa','yes','no') decode from ...

  2. 10.8 android输入系统_实战_使用GlobalKey一键启动程序

    11. 实战_使用GlobalKey一键启动程序参考文章:Android 两种注册(动态注册和静态注册).发送广播的区别http://www.jianshu.com/p/ea5e233d9f43 [A ...

  3. POS的一点杂笔

    仅限于POS 仅限于POS 仅限于POS A 字母字符 N 数字 S 特殊字符 an 字母和数字字符 as 字母和特殊字符 ns 数字和特殊字符 ans 字母.数字和特殊字符 MM 月份 DD 日期 ...

  4. Spring-Boot整合freemarker引入静态资源css、js等(转)

    一.概述 springboot 默认静态资源访问的路径为:/static 或 /public 或 /resources 或 /META-INF/resources 这样的地址都必须定义在src/mai ...

  5. [spark]Spark Streaming教程

      (一)官方入门示例 废话不说,先来个示例,有个感性认识再介绍. 这个示例来自spark自带的example,基本步骤如下: (1)使用以下命令输入流消息: $ nc -lk 9999 (2)在一个 ...

  6. Java 开源博客——B3log Solo 0.6.7 正式版发布了!

    Java 开源博客 -- B3log Solo 0.6.7 正式版发布了!欢迎大家下载. 另外,欢迎观摩 B3log 团队的新项目:Wide,也非常欢迎大家参与进来 :-) 特性 基于标签的文章分类 ...

  7. python画最最简单的折线图

    # encoding=utf-8import matplotlib.pyplot as pltfrom pylab import * #支持中文mpl.rcParams['font.sans-seri ...

  8. Win7下多线程中OpenFileDialog和SaveFileDialog失效的解决办法(转载)

    在程序中,通常会使用独立线程来操作OpenFileDialog或者SaveFileDialog控件,但是在某些情况下(Win7系统下)调用 ShowDialog方法并不显示选择路径对话框.此时需要对启 ...

  9. 数据类型总结——Boolean类型(布尔类型)

    相关文章 简书原文:https://www.jianshu.com/p/e5c75d4be636 数据类型总结——概述:https://www.cnblogs.com/shcrk/p/9266015. ...

  10. JavaScript的return程序流

    原文 简书原文:https://www.jianshu.com/p/cd65a26a5b0c 大纲 1.场景分析 2.代码分析 3.总结分析 1.场景分析 以下有两段代码,这两段代码都可以使用检查输入 ...