1. 程式人生 > >CF802G Fake News (easy)

CF802G Fake News (easy)

ref space ant other clas mes == sed str

CF802G Fake News (easy)

題意翻譯

給定一個字符串詢問能否聽過刪除一些字母使其變為“heidi”

如果可以輸出“YES”,不然為“NO”

題目描述

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

輸入輸出格式

輸入格式:

The first and only line of input contains a single nonempty string ss of length at most 10001000 composed of lowercase letters (a-z).

輸出格式:

Output YES if the string ss contains heidi as a subsequence and NO otherwise.

輸入輸出樣例

輸入樣例#1: 復制
abcheaibcdi
輸出樣例#1: 復制
YES
輸入樣例#2: 復制
hiedi
輸出樣例#2: 復制
NO

說明

A string ss contains another string pp as a subsequence if it is possible to delete some characters from ss and obtain pp .

技術分享圖片

#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using
namespace std; char ch[1100]; queue<char> que; int main() { que.push(h);que.push(e);que.push(i); que.push(d);que.push(i);cin>>ch; int len=strlen(ch); for(int i=0;i<len;i++) if(!que.empty()) if(ch[i]==que.front()) que.pop(); if(que.empty()) cout<<"YES"; else cout<<"NO"; }

CF802G Fake News (easy)