【非常高%】【codeforces 733A】Grasshopper And the String
来源:互联网 发布:网络电话录音 编辑:程序博客网 时间:2024/05/01 07:03
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 longusing 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
- Codeforces 733A Grasshopper And the String
- codeforces--733A. Grasshopper And the String
- CodeForces 733A - Grasshopper And the String
- Codeforces 733A Grasshopper And the String
- 733A Grasshopper And the String codeforces(水题)
- CodeForces 733A Grasshopper And the String(水题)
- CodeForces 733 A.Grasshopper And the String(水~)
- 733A Grasshopper And the String
- A. Grasshopper And the String
- A. Grasshopper And the String
- Codeforces Round #378 (Div. 2)A. Grasshopper And the String
- Codeforces Round #378 (Div. 2) A. Grasshopper And the String
- codeforces#378 Div.2 A. Grasshopper And the String
- [codeforces] A. Grasshopper And the String 简单模拟
- codeforces 733A 733B之Grasshopper And the String Parade
- CodeForces 733A Grasshopper And the String(蚂蚱跳字符)
- 【codeforces】Grasshopper And the String(div2A)
- BSOJ 3022 又一类数字三角形--根据数据范围的优化+背包思想递推/搜索
- Atitit 编程语言原理与概论attilax总结 三大书籍总结
- TCP迭代服务器
- 《算法竞赛入门经典》第四章总结
- MySQL之MySQL5.7中文乱码
- 【非常高%】【codeforces 733A】Grasshopper And the String
- UE4 4.13 引擎bug
- 扒一扒 laravel的消息通知(上)
- LeetCode 171. Excel Sheet Column Number
- pip或者pycharm安装模块出错问题
- 汇编语言--寄存器间接寻址
- 设计模式六大原则(1):单一职责原则(转载)
- 【贪心】CODE[VS] 3377 [Mz]接水问题2 (模拟+优先队列(堆))
- 第八周训练a题 Balance