社区讨论
蒟蒻求助!样例全过但不能AC!!
CF802GFake News (easy)参与者 2已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 3 条
- 当前快照
- 1 份
- 快照标识符
- @locllvnv
- 此快照首次捕获于
- 2023/10/30 15:48 2 年前
- 此快照最后确认于
- 2023/11/05 02:57 2 年前
代码如下
CPP#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <queue>
#include <vector>
#include <stack>
#include <list>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main() {
string s;
cin >> s;
queue<char>q;
for (int i = 0; i < s.length(); i++) {
if (s[i] == 'h')q.push(s[i]);
if (s[i] == 'e' && !q.empty()) { if (q.back() == 'h')q.push(s[i]); }
if (s[i] == 'i' && !q.empty()) { if (q.back() == 'e')q.push(s[i]); }
if (s[i] == 'd' && !q.empty()) { if (q.back() == 'i')q.push(s[i]); }
if (s[i] == 'i' && !q.empty()) { if (q.back() == 'd')q.push(s[i]); }
}
string a = "";
for (int i = 0; i < 200; i++) {
if (q.empty())break;
a += q.front();
if (a == "heidi") { cout << "YES"; return 0; }
q.pop();
}
cout << "NO";
return 0;
}
回复
共 3 条回复,欢迎继续交流。
正在加载回复...