Time limit : 2sec / Memory limit : 256MB

Score : 200 points

Problem Statement

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 ab 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 SASB 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 SASBSC is ab or c.

Input

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

SA
SB
SC

Output

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


Sample Input 1

Copy
aca
accc
ca

Sample Output 1

Copy
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.

Sample Input 2

Copy
abcb
aacb
bccc

Sample Output 2

Copy
C

题解:不知道为啥队列就会哇  还是直接模拟

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include <queue>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll gcd(ll a,ll b){
return b?gcd(b,a%b):a;
}
bool cmp(int x,int y)
{
return x>y;
}
const int N=;
const int mod=1e9+;
char A[],B[],C[];
int main()
{
int a,b,c;
int la,lb,lc;
while(cin>>A>>B>>C){
int tmp;
la=strlen(A),lb=strlen(B),lc=strlen(C);
tmp=,a=b=c=-;
while(){
if(a==la){
cout<<"A"<<endl;
break;
}
else if(b==lb){
cout<<"B"<<endl;
break;
}
else if(c==lc){
cout<<"C"<<endl;
break;
}
if(tmp==){
a++;
tmp=A[a]-'a'+;
}
else if(tmp==){
b++;
tmp=B[b]-'a'+; }
else if(tmp==){
c++;
tmp=C[c]-'a'+;
}
}
}
return ;
}

AtCoder Beginner Contest 045 B - 3人でカードゲームイージー / Card Game for Three (ABC Edit)的更多相关文章

  1. AtCoder Beginner Contest 044 A - 高橋君とホテルイージー / Tak and Hotels (ABC Edit)

    Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement There is a hotel with ...

  2. AtCoder Beginner Contest 045 C - たくさんの数式 / Many Formulas

    Time limit : 2sec / Memory limit : 256MB Score : 300 points Problem Statement You are given a string ...

  3. AtCoder Beginner Contest 053 ABCD题

    A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...

  4. AtCoder Beginner Contest 153 题解

    目录 AtCoder Beginner Contest 153 题解 A - Serval vs Monster 题意 做法 程序 B - Common Raccoon vs Monster 题意 做 ...

  5. AtCoder Beginner Contest 173 题解

    AtCoder Beginner Contest 173 题解 目录 AtCoder Beginner Contest 173 题解 A - Payment B - Judge Status Summ ...

  6. AtCoder Beginner Contest 172 题解

    AtCoder Beginner Contest 172 题解 目录 AtCoder Beginner Contest 172 题解 A - Calc B - Minor Change C - Tsu ...

  7. AtCoder Beginner Contest 148 题解

    目录 AtCoder Beginner Contest 148 题解 前言 A - Round One 题意 做法 程序 B - Strings with the Same Length 题意 做法 ...

  8. AtCoder Beginner Contest 238 A - F 题解

    AtCoder Beginner Contest 238 \(A - F\) 题解 A - Exponential or Quadratic 题意 判断 \(2^n > n^2\)是否成立? S ...

  9. AtCoder Beginner Contest 100 2018/06/16

    A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...

随机推荐

  1. Finecms模板标签调用小结 方便快速入门

    最近接了一个单子客户要求用finecms进行建站,由于也是php代码,也可以直接调用相关函数,所以上手相对比较快,ytkah总结了一些常用的函数方便您快速入门Finecms.一个网站一般由主页.栏目页 ...

  2. 香港低价linux虚拟主机,

    https://www.sugarhosts.com/zh-cn/hosting/shared-web-hosting Shared Baby 36 个月 ¥ 26.99 19 99 · / 月 续费 ...

  3. TCP、UDP和HTTP详解

    http:是用于www浏览的一个协议.tcp:是机器之间建立连接用的到的一个协议. 1.TCP/IP是个协议组,可分为三个层次:网络层.传输层和应用层.在网络层有IP协议.ICMP协议.ARP协议.R ...

  4. mac上mysql root密码忘记或权限错误的解决办法

    以下方法亲测有效,过程使用的工具只有mac的终端无需workbench 当我们通过终端连接mysql数据库时候我们会看到这样的信息 ERROR 1045: Access denied for user ...

  5. [py]py异常应用

    异常执行路径 代码参考 try: text = input('请输入 --> ') except EOFError: print('为什么你按下了EOF?') except KeyboardIn ...

  6. Java字符串复制

    Java字符串复制 public boolean topicFilterMatch(String topicFilter, String topic) { if (topicFilter == nul ...

  7. Linux个人知识扩展:服务器几u的意思,网络带宽

    服务器几u的意思: 指的服务器大小规格 1U=4.45cm 2U=8.9cm 3U=4.45cm * 3 4U=4.45cm * 4 这指的是服务器的高度 现在的服务器为节省空间都是很扁的 U是服务器 ...

  8. linux中 /dev/null命令

    /dev/null :代表空设备文件 >  :代表重定向到哪里,例如:echo "123" > /home/123.txt1  :表示stdout标准输出,系统默认值是 ...

  9. 【Java】-NO.16.EBook.4.Java.1.009-【疯狂Java讲义第3版 李刚】- 泛型

    1.0.0 Summary Tittle:[Java]-NO.16.EBook.4.Java.1.009-[疯狂Java讲义第3版 李刚]- 泛型 Style:EBook Series:Java Si ...

  10. js多个异步请求,按顺序执行next

    在js里面,偶尔会遇见需要多个异步按照顺序执行请求,又不想多层嵌套,,这里和promise.all的区别在于,promise或者Jquery里面的$.when 是同时发送多个请求,一起返回,发出去的顺 ...