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 ...
随机推荐
- 题解【POJ3252】Round Numbers
Description The cows, as you know, have no fingers or thumbs and thus are unable to play Scissors, P ...
- Vue的响应式原理---(v-model中的双向绑定原理)
Vue响应式原理 不要认为数据发生改变,界面跟着更新是理所当然. 具体代码实现:https://gitee.com/ahaMOMO/Vue-Responsive-Principle.git 看下图: ...
- 【游戏体验】FlyGuy(小飞人)
关于FlyGuy这款游戏:https://en.wikipedia.org/wiki/Fly_Guy_(video_game) 这款游戏可以说是古董了 游戏的自由度比较高,玩法简单. 个人测评 游戏性 ...
- linux系统下如何打开端口
1)vi /etc/sysconfig/iptables 2)-A INPUT -m state --state NEW -m tcp -p tcp --dport xxxxxxxxxx -j ACC ...
- 第二十三篇 玩转数据结构——栈(Stack)
1.. 栈的特点: 栈也是一种线性结构: 相比数组,栈所对应的操作是数组的子集: 栈只能从一端添加元素,也只能从这一端取出元素,这一端通常称之为"栈顶": 向栈中添加元 ...
- android底部导航栏实现
第一种用radiobutton实现 https://wizardforcel.gitbooks.io/w3school-android/content/75.html 布局文件,使用radiogrou ...
- ci/cd部署时遇到的一个问题
今天在部署项目的时候报了一个错Error response from daemon: endpoint with name xxx already exists in networ ...
- LR编写webservice协议接口
转自:http://lovesoo.org/use-loadrunner-call-webservice-interface-testing-optimization-summary.html 本文主 ...
- tomcat服务器启动执行的两个方法
第一 SetApplicationContext(需要继承ApplicationContextAware)重写 第二 ContextInitialize(需要继承servleContet)重写,(co ...
- Springmvc-crud-05(路径错误)
错误: 原因:Tomcat8之后的一些高版本,使用restful风格访问然后转发到jsp页面,进行业务操作时会报路径错误 解决方案①:修改jsp页面中的page指令isErrorPage=" ...