Codeforces 989A A Blend of Springtime

 

The landscape can be expressed as a row of consecutive cells, each of which either contains a flower of colour amber or buff or canary yellow, or is empty.

When a flower withers, it disappears from the cell that it originally belonged to, and it spreads petals of its colour in its two neighbouring cells (or outside the field if the cell is on the side of the landscape). In case petals fall outside the given cells, they simply become invisible.

You are to help Kanno determine whether it's possible that after some (possibly none or all) flowers shed their petals, at least one of the cells contains all three colours, considering both petals and flowers. Note that flowers can wither in arbitrary order.

Input

The first and only line of input contains a non-empty string ss consisting of uppercase English letters 'A', 'B', 'C' and characters '.' (dots) only (|s|≤100|s|≤100) — denoting cells containing an amber flower, a buff one, a canary yellow one, and no flowers, respectively.

Output

Output "Yes" if it's possible that all three colours appear in some cell, and "No" otherwise.

You can print each letter in any case (upper or lower).

Examples

input

Copy

.BAC.

output

Copy

Yes

input

Copy

AA..CB

output

Copy

No

Note

In the first example, the buff and canary yellow flowers can leave their petals in the central cell, blending all three colours in it.

In the second example, it's impossible to satisfy the requirement because there is no way that amber and buff meet in any cell.

 

大概意思就是,给你一排连续的花盆,每盆种了一种花(一共三种颜色“A”“B”“C”),也有可能放空盆,当一盆花凋谢的时候,她的花瓣会分别掉进相邻的两个花盆,自己盆就啥也没有了,问你有没有可能一个花盆里同时存在三种不同颜色的花瓣,注意花的凋谢时间任意,比如第一个样例,就是B,C的花瓣都掉进了A的盆,而A没凋谢,所以A的盆中有3种颜色的花瓣:

 

稍微想想,要想能符合目标,那肯定就只有三盆颜色不一样的连着放才行,所以,问题就转化为,找字符串里面有没有“ABC”,“BAC”,"CAB".......这类的子串,

#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
	while(cin>>a){
	 bool f=false;
	 if(a.length()<3){
	 	cout<<"No"<<endl;
	 	continue;                //字符串长度不够,输出NO
	 }
	 for(int i=0;i<=a.length()-3;i++){
	 	b=a.substr(i,3);       //每次截取长度为3的子串
	 	if(b[0]!='.'&&b[1]!='.'&&b[2]!='.'){
	 		if(b[0]!=b[1]&&b[1]!=b[2]&&b[2]!=b[0]){
	 			f=true;
	 			break;          //判断
			 }
		 }
	 	b.clear();
	 }
	 if(f) cout<<"Yes"<<endl;
	 else cout<<"No"<<endl;}
   return 0;

}

 

发布了153 篇原创文章 · 获赞 43 · 访问量 6万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 技术黑板 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览