Alice, Bob and Charlie are playing Card Game for Three, as below:

At first, each of the three players has a deck consisting of some number of cards. Each card has a letter a, b or c written on it. The orders of the cards in the decks cannot be rearranged.

The players take turns. Alice goes first.

If the current player’s deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says a, Alice takes the next turn.)

If the current player’s deck is empty, the game ends and the current player wins the game.

You are given the initial decks of the players. More specifically, you are given three strings SA, SB and SC. The i-th (1≦i≦|SA|) letter in SA is the letter on the i-th card in Alice’s initial deck. SB and SC describes Bob’s and Charlie’s initial decks in the same way.

Determine the winner of the game.

Constraints

1≦|SA|≦100

1≦|SB|≦100

1≦|SC|≦100

Each letter in SA, SB, SC is a, b or c.

输入

The input is given from Standard Input in the following format:

SA

SB

SC

输出

If Alice will win, print A. If Bob will win, print B. If Charlie will win, print C.

样例输入

aca
accc
ca

样例输出

A

提示

The game will progress as below:

Alice discards the top card in her deck, a. Alice takes the next turn.

Alice discards the top card in her deck, c. Charlie takes the next turn.

Charlie discards the top card in his deck, c. Charlie takes the next turn.

Charlie discards the top card in his deck, a. Alice takes the next turn.

Alice discards the top card in her deck, a. Alice takes the next turn.

Alice’s deck is empty. The game ends and Alice wins the game.

#include <bits/stdc++.h>
using namespace std;
string a,b,c;
int sa,sb,sc;
int bn;
int la = -1,lb = -1,lc = -1;
int main(){
//freopen("in","r",stdin);
cin >> a >> b >> c; sa = a.size();
sb = b.size();
sc = c.size();
bn = 1;
while(1) {
if(la == sa){
puts("A");
break;
}else if(lb == sb){
puts("B");
break;
}else if(lc == sc){
puts("C");
break;
}
if (bn == 1) {
la++;
bn = a[la] - 'a' + 1;
} else if (bn == 2) {
lb++;
bn = b[lb] - 'a' + 1;
} else if (bn == 3) {
lc++;
bn = c[lc] - 'a' + 1;
} }
return 0;
}

Card Game for Three的更多相关文章

  1. Lesson 3 Please send me a card

    Text Postcards always spoil my holidays. Last summer, I went to Italy. I visited museums and sat in ...

  2. iOS - Card Identification 银行卡号识别

    1.CardIO 识别 框架 GitHub 下载地址 配置 1.把框架整个拉进自己的工程,然后在 TARGETS => Build Phases => Link Binary With L ...

  3. HDOJ 4336 Card Collector

    容斥原理+状压 Card Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  4. Opensuse enable sound and mic card

    Install application pavucontrol Run pavucontrol You will see the configuration about sound card and ...

  5. 进监狱全攻略之 Mifare1 Card 破解

    补充新闻:程序员黑餐馆系统 给自己饭卡里充钱 ,技术是双刃剑,小心,小心! 前言 从M1卡的验证漏洞被发现到现今,破解设备层出不穷,所以快速傻瓜式一键破解不是本文的重点,年轻司机将从本文中获得如下技能 ...

  6. Card(bestcoder #26 B)

    Card Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

  7. [OpenJudge 3061]Flip The Card

    [OpenJudge 3061]Flip The Card 试题描述 There are N× Ncards, which form an N× Nmatrix. The cards can be p ...

  8. [杂谈]交通工具orca card

    How and Where to Use the ORCA Card The Microsoft ORCA card provides unlimited rides on all buses, tr ...

  9. [OrangePi] Backup internal EMMC to SD Card

    Boot your Orange PI board from EMMC without SD Card inserted login insert your SD Card Run: sudo ins ...

  10. [OrangePi] Installation on SD Card

    Download any of the available images (xz archive) from Mega or GoogleDrive Download scriptbin_kernel ...

随机推荐

  1. [NLP]Transformer-XL论文解读

    关于Transformer的具体内容,可以访问:https://www.cnblogs.com/mj-selina/p/12369797.html 简介 Transformer是Google Brai ...

  2. 后端——框架——日志框架——logback——《官网》阅读笔记——第一章节

    第一章节搭建了logback日志框架的环境,演示了Hello World的示例,并详细分析了示例. 搭建日志框架的过程非常简单,只需要在项目的classpath上添加以下三个jar包,logback- ...

  3. LED Decorative Light Manufacturer - LED Neon Rope: 5 Advantages

    In the past 100 years, lighting has come a long way. Nowadays, the decorative LED lighting design ca ...

  4. Qt那点事儿(一)

    原文http://www.cnblogs.com/andreitang/archive/2011/08/03/2125815.html 第一回 Signal和Slot是同步的还是异步的? 我们知道Qt ...

  5. bugku 前女友

    首先打开链接然后会发现 照常情况下进行分析 查看源码然后发现 在这一串文字后还有一个链接然后 发现链接被隐藏了然后我们将link 删除就会显示出来点开新的连接 然后会发现这个 (仔细一看好像是php中 ...

  6. javaWeb核心技术之分页和条件

    分页:limit ?,? 参数1 : startIndex 开始索引. 参数2 : pageSize 每页显示的个数 n 表示第几页 给定一个特殊的单词 pageNumber select * fro ...

  7. 吴裕雄 python 机器学习——半监督学习LabelSpreading模型

    import numpy as np import matplotlib.pyplot as plt from sklearn import metrics from sklearn import d ...

  8. C9300升级-TFTP

    1.操作命令:CAT9300(config)#ip tftp blocksize 8192CAT9300(config)#install add file tftp://10.1.100.37/cat ...

  9. 动手实现CapsNet系列——2 实现(未完待续)

    执行后返回如下信息: Loading complete. Training started! [epoch 0][iter 0] loss: 0.8082, acc: 14.0000% (14/100 ...

  10. 关于pgsql 的json 和jsonb 的数据查询操作笔记整理

    关于pgsql 的json 和jsonb 的数据处理笔记 1. json 和jsonb 区别两者从用户操作的角度来说没有区别,区别主要是存储和读取的系统处理(预处理)和耗时方面有区别.json写入快, ...