codeforces 989A A Blend of Springtime

Posted wx62f0894128448

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了codeforces 989A A Blend of Springtime相关的知识,希望对你有一定的参考价值。


​http://www.elijahqi.win/archives/3658​​​
题目描述
When the curtains are opened, a canvas unfolds outside. Kanno marvels at all the blonde colours along the riverside — not tangerines, but blossoms instead.”What a pity it’s already late spring,” sighs Mino with regret, “one more drizzling night and they’d be gone.”

“But these blends are at their best, aren’t they?” Absorbed in the landscape, Kanno remains optimistic.

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.

输入输出格式
输入格式:

The first and only line of input contains a non-empty string

s

s consisting of uppercase English letters ‘A’, ‘B’, ‘C’ and characters ‘.’ (dots) only (

\\lvert s \\rvert \\leq 100

∣s∣≤100 ) — denoting cells containing an amber flower, a buff one, a canary yellow one, and no flowers, respectively.

输出格式:

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

输入输出样例
输入样例#1: 复制

.BAC.
输出样例#1: 复制

Yes
输入样例#2: 复制

AA..CB
输出样例#2: 复制

No
说明
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.

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int flag[110][3],ans;char s[110];
int main()
freopen("a.in","r",stdin);
scanf("%s",s+1);
for (int i=1;s[i];++i)
if(s[i]==.) continue;++flag[i][s[i]-A];
++flag[i-1][s[i]-A];++flag[i+1][s[i]-A];

for (int i=1;s[i];++i)
if (flag[i][0]>=1&&flag[i][1]>=1&&flag[i][2]>=1) ans=1;break;

ans?puts("Yes"):puts("No");
return 0;


以上是关于codeforces 989A A Blend of Springtime的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces Round #234A

CSS3混合模式mix-blend-mode/background-blend-mode简介

CodeForces 796A Buying A House

Codeforces 731F Video Cards

Codeforces Round 870 (A-D)

Codeforces 220B - Little Elephant and Array 离线树状数组