Hello 2019 A

2019-01-05 02:12:34


题目链接:

https://codeforces.com/contest/1097/problem/A

原题:

Problem Statement

Gennady owns a small hotel in the countryside where he lives a peaceful life. He loves to take long walks, watch sunsets and play cards with tourists staying in his hotel. His favorite game is called "Mau-Mau".

To play Mau-Mau, you need a pack of 52 cards. Each card has a suit (Diamonds — D, Clubs — C, Spades — S, or Hearts — H), and a rank (2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K, or A).

At the start of the game, there is one card on the table and you have five cards in your hand. You can play a card from your hand if and only if it has the same rank or the same suit as the card on the table.

In order to check if you'd be a good playing partner, Gennady has prepared a task for you. Given the card on the table and five cards in your hand, check if you can play at least one card.

Input

The first line of the input contains one string which describes the card on the table. The second line contains five strings which describe the cards in your hand.

Each string is two characters long. The first character denotes the rank and belongs to the set {2,3,4,5,6,7,8,9,T,J,Q,K,A}. The second character denotes the suit and belongs to the set {D,C,S,H}.

All the cards in the input are different.

Output

If it is possible to play a card from your hand, print one word "YES". Otherwise, print "NO".

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

Examples

input1

AS
2H 4C TH JH AD

output1

YES

input2

2H
3D 4C AC KD AS

output2

NO

input3

4D
AS AC AD AH 5H

output3

YES

Note

In the first example, there is an Ace of Spades (AS) on the table. You can play an Ace of Diamonds (AD) because both of them are Aces.

In the second example, you cannot play any card.

In the third example, you can play an Ace of Diamonds (AD) because it has the same suit as a Four of Diamonds (4D), which lies on the table.


题意:

你有五张牌,给定一张牌,判断这张牌是否和你五张牌中有相同花色或者点数。

思路:

水题,简单模拟即可

AC代码:

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#include<set>
typedef long long ll;
#include<vector>
#define cin(n) scanf("%lld",&(n))
#define cout(n) printf("%lld",(n))
#define couc(c) printf("%c",(c))
#define coutn printf("\n")
#define cout_ printf(" ")
#define debug() printf("haha\n")
const int MAXN =10000005;
ll t,n,k;
ll a[MAXN];
ll ansa,ansb;
ll MIN=0x3f3f3f3f;
ll ans;
float fa,fb;
double da,db,dc,dlat,dans;
double dan[MAXN];
double eps=1e-6;
char ch;
int mpa[105][105];
int mpb[105][105];
std::string s[10],sb;
int main()
{
    std::cin>>s[0];
    for(int i=1;i<=5;i++)
    {
        std::cin>>s[i];
        if(s[0][0]==s[i][0]||s[0][1]==s[i][1])
        {
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
    return 0;
}