AtCoder Beginner Contest 211

B - Cycle Hit

Problem Statement

You are given four strings S1S1, S2S2, S3S3, and S4S4.
Determine whether this sequence of strings has one of each of the following: H2B3B, and HR.
Here, it is guaranteed that every SiSi is H2B3B, or HR.

Constraints

  • Each SiSi is H2B3B, or HR.

Input

Input is given from Standard Input in the following format:

S1S1
S2S2
S3S3
S4S4

Output

If the given sequence of strings has one of each of H2B3B, and HR, print Yes.
Otherwise, print No.

Sample Input 1 Copy

Copy

3B
HR
2B
H

Sample Output 1 Copy

Copy

Yes

We have one of each of H2B3B, and HR.

Sample Input 2 Copy

Copy

2B
3B
HR
3B

Sample Output 2 Copy

Copy

No

We have no H.


尝试用向量来写,注意输出的大小写

#include <bits/stdc++.h>
using namespace std;
int main(){
	string s[5];
	for(int i = 0;i < 4; i++)
	cin >> s[i];
	string c[4] = {"HR", "3B", "2B", "H"};
	vector<string> b(c, c + 4), a;
	
	for(int i = 0; i < 4; i ++){
		a.push_back(s[i]);
		for(int j = 0; j < b.size(); j++){
			if(a[i] == b[j]) {
				b.erase(b.begin()+j, b.begin()+j+1);
			}
		}
	}
	if(b.empty()) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

SUGA no sugar

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值