Card Game for Three
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的更多相关文章
- 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 ...
- iOS - Card Identification 银行卡号识别
1.CardIO 识别 框架 GitHub 下载地址 配置 1.把框架整个拉进自己的工程,然后在 TARGETS => Build Phases => Link Binary With L ...
- HDOJ 4336 Card Collector
容斥原理+状压 Card Collector Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
- Opensuse enable sound and mic card
Install application pavucontrol Run pavucontrol You will see the configuration about sound card and ...
- 进监狱全攻略之 Mifare1 Card 破解
补充新闻:程序员黑餐馆系统 给自己饭卡里充钱 ,技术是双刃剑,小心,小心! 前言 从M1卡的验证漏洞被发现到现今,破解设备层出不穷,所以快速傻瓜式一键破解不是本文的重点,年轻司机将从本文中获得如下技能 ...
- Card(bestcoder #26 B)
Card Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- [OpenJudge 3061]Flip The Card
[OpenJudge 3061]Flip The Card 试题描述 There are N× Ncards, which form an N× Nmatrix. The cards can be p ...
- [杂谈]交通工具orca card
How and Where to Use the ORCA Card The Microsoft ORCA card provides unlimited rides on all buses, tr ...
- [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 ...
- [OrangePi] Installation on SD Card
Download any of the available images (xz archive) from Mega or GoogleDrive Download scriptbin_kernel ...
随机推荐
- 1015 Reversible Primes
1. 题目 2. 抽象建模 无 3. 方法 无 4. 注意点 素数判断(1不是素数) 数值的倒转 5. 代码 #include<stdio.h> #include<math.h> ...
- Yii2.0 高级版修改默认访问控制器
frontend->config->main-local.php $config = [ 'defaultRoute' => 'index/index',//修改默认访问控制器 'c ...
- Codeforces Round #525 (Div. 2) C. Ehab and a 2-operation task 数学 mod运算的性质
C. Ehab and a 2-operation task 数学 mod运算的性质 题意: 有两种对前缀的运算 1.对前缀每一个\(a +x\) 2.对前缀每一个\(a\mod(x)\) 其中x任选 ...
- Redis 配置文件杂项。
protected-mode -----------------保护模式 redis3.2版本后新增protected-mode配置,默认是yes,即开启.设置外部网络连接redis服务,设置方式如下 ...
- c++基础语法规则
1,c++存储类:定义函数或者变量的生命周期 auto 关键字用于两种情况:声明变量时根据初始化表达式自动推断该变量的类型.声明函数时函数返回值的占位符. register 存储类用于定义存储 ...
- layui与jQuery一起使用
1,先导入jquery <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2 ...
- .h头文件 .lib库文件 .dll动态链接库文件关系
.h头文件是编译时必须的,lib是链接时需要的,dll是运行时需要的. 附加依赖项的是.lib不是.dll,若生成了DLL,则肯定也生成 LIB文件.如果要完成源代码的编译和链接,有头文件和lib就够 ...
- vue项目怎么搭建到云服务器上
链接1:https://blog.csdn.net/qq_37741554/article/details/87560823 linux下载安装node.js 链接2:https://blog.csd ...
- Atcoder Beginner Contest153F(模拟)
应该也可以用线段树/树状数组区间更新怪兽的生命值来做 #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespac ...
- 五种网络IO模型以及多路复用IO中select/epoll对比
下面都是以网络读数据为例 [2阶段网络IO] 第一阶段:等待数据 wait for data 第二阶段:从内核复制数据到用户 copy data from kernel to user 下面是5种网络 ...