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 ...
随机推荐
- [POI2011]ROT-Tree Rotations 线段树合并|主席树 / 逆序对
题目[POI2011]ROT-Tree Rotations [Description] 现在有一棵二叉树,所有非叶子节点都有两个孩子.在每个叶子节点上有一个权值(有\(n\)个叶子节点,满足这些权值为 ...
- Go网络编程UDP
package main import ( "fmt" "net" "strings" ) // UDP server func main( ...
- AJAX--XMLHttpRequest对象
创建XMLHttpRequest对象 XMLHttpRequest是AJAX的基础. 所有现代浏览器(IE7+.Firefox.Chrome.Safari以及Opera)均内建XMLHttpReque ...
- HTML学习(10)图像
HTML图像标签<img>,没有闭合标签 <img src="" alt="" width="" height=" ...
- 各技能DBC参数
推荐你 通过 引擎的帮助文件查找标准魔法DB 下面是 部分hero引擎的标准魔法DB 34,解毒术,2,26,16,0,0,0,0,0,2,42,50,44,100,46,200,40,, 35,老 ...
- Java正则表达式提取String字符串中的IP地址
/** * 正则提前字符串中的IP地址 * @param ipString * @return */ public static List<String> getIps(String ip ...
- pandas 数据可视化之折线图
官网地址:https://openpyxl.readthedocs.io/en/stable/charts/line.html#id1 openpyxl+pandas # coding=utf-8 i ...
- Linux - Linux中线程为何有PID?
重现 用htop的Tree view(按F5)之后查看线程 参考 https://segmentfault.com/q/1010000003586656 mousycoder的回答 https://u ...
- (matlab)自定义图像(matlab)
clc;clear all;A=[0 230 255 60 30 100];A=uint8(A);imshow(A,'InitialMagnification','fit') 如图: clc;clea ...
- VIM - EX 命令 - 文件读写
VIM - EX 命令 - 文件读写 1. 概述 vim 通过 ex 命令行, 与其他文件的读写操作 2. 场景 场景1 vim 打开文本 将当前文本的内容, 写入到其他文本 场景2 vim 打开文本 ...