CF1097A.Gennady and a Card Game
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
根纳季在乡下拥有一家小旅馆,过着平静的生活。他喜欢长时间散步、观赏日落,还喜欢和住在旅馆里的游客玩纸牌游戏。他最喜欢的游戏叫做“毛毛”(Mau-Mau)。
要玩“毛毛”,你需要一副 52 张的扑克牌。每张牌都有一个花色(方块 — D、梅花 — C、黑桃 — S 或红桃 — H)和一个点数(2、3、4、5、6、7、8、9、T、J、Q、K 或 A)。
游戏开始时,桌面上有一张牌,而你手中有五张牌。当且仅当你手中的某张牌与桌面上的牌具有相同的点数或相同的花色时,你才可以打出这张牌。
为了检验你是否是一位优秀的搭档,根纳季为你准备了一个任务:给定桌面上的一张牌以及你手中的五张牌,请判断你是否至少能打出一张牌。
输入格式
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.
输入的第一行包含一个字符串,表示桌面上的牌。第二行包含五个字符串,表示你手上的牌。
每个字符串长度为两个字符。第一个字符表示点数,属于集合 {2,3,4,5,6,7,8,9,T,J,Q,K,A};第二个字符表示花色,属于集合 {D,C,S,H}。
输入中的所有牌均不相同。
输出格式
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).
如果可以从手牌中打出一张牌,则输出一个单词 “YES”;否则输出 “NO”。
每个字母可以以任意大小写形式输出(大写或小写)。
输入输出样例
输入#1
AS 2H 4C TH JH AD
输出#1
YES
输入#2
2H 3D 4C AC KD AS
输出#2
NO
输入#3
4D AS AC AD AH 5H
输出#3
YES
说明/提示
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.
在第一个例子中,桌面上有一张黑桃A(AS)。你可以出一张方块A(AD),因为它们都是A。
在第二个例子中,你无法出任何牌。
在第三个例子中,你可以出一张方块A(AD),因为它与桌面上的方块4(4D)花色相同。
输入解题思路,AI测评打分。不知道怎么写?