Codeforces contest 802 problem G
来源:互联网 发布:菜鸟网络能上市吗? 编辑:程序博客网 时间:2024/06/04 19:32
Codeforces contest 802 problem G Fake News (easy)
Description
As it's the first of April, Heidi is suspecting that the news she reads today are fake, and she does not want to look silly in front of all the contestants. She knows that a newspiece is fake if it contains heidi as a subsequence. Help Heidi assess whether the given piece is true, but please be discreet about it...
Input
The first and only line of input contains a single nonempty string s of length at most 1000 composed of lowercase letters (a-z).
Output
Output YES if the string s contains heidi as a subsequence and NO otherwise.
Examples
//
Note
A string s contains another string p as a subsequence if it is possible to delete some characters from s and obtain p.
problem详见:http://codeforces.com/contest/802/problem/G
水模拟,只要注意一下小于其的长度即可!
#include <iostream>#include <cstdio>#include <cmath>#include <cstring>#include <cstdlib>#include <ctime>#include <climits>#include <algorithm>#include <string>using namespace std;const int len = 100010;char a[len];string b="heidi";bool pd(char a[],int n){ bool ans; int i = 0; for (int j=0;j<5;j++) { ans = false; while (i<n) { if (a[i] == b[j]) {ans = true;i++;break;} i++; } if (!ans) return false; } return true;}int main() { //freopen("test.in","r",stdin); scanf("%s",a); int n = strlen(a); if (n==5 && a[0] == 'h' && a[1] == 'e' && a[2] == 'i' && a[3] == 'd' && a[4] == 'i') cout << "YES" << endl; else { if (n <= 5) cout << "NO" << endl; else { if (pd(a,n)) cout << "YES" <<endl; else cout << "NO" << endl; } } return 0;}
- Codeforces contest 802 problem G
- codeforces contest/796/problem/D
- codeforces/contest/796/problem/E
- codeforces/contest/797/problem/A
- codeforces/contest/797/problem/B
- codeforces/contest/797/problem/E
- codeforces/contest/798/problem/B
- 【codeforces】2014 Asia Xian Regional Contest G The Problem to Slow Down You 【Palindromic Tree】
- codeforces 45G Prime Problem
- http://codeforces.com/contest/6/problem/A
- http://codeforces.com/contest/7/problem/B
- http://codeforces.com/contest/7/problem/A
- http://codeforces.com/contest/1/problem/A
- http://codeforces.com/contest/1/problem/B
- http://codeforces.com/contest/263/problem/D
- http://codeforces.com/contest/276/problem/C
- codeforces.com/contest/325/problem/B
- http://codeforces.com/contest/366/problem/D
- 2017-05-30:Unity5.6.1实现联网模式下控制多玩家在场景中的移动
- TFcaiCH3
- fl2440模块学习——3G拨号上网
- <? extends T>和<? super T>
- SpringBoot应用监控
- Codeforces contest 802 problem G
- 解决用php连接本地数据库慢的问题
- HTTP协议
- webservice接口调用
- DXP的使用过程
- 基于LPC2364的串口转网口专用协议卡的研制
- Problem B: 寻找学生
- List<List<E>> list = new ArrayList<ArrayList<E>>()报错的解决方法
- python matplotlib imshow显示问题