AtCoder Beginner Contest 045 B - 3人でカードゲームイージー / Card Game for Three (ABC Edit)
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
a
,b
orc
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
orc
.
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
aca
accc
ca
Sample Output 1
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
abcb
aacb
bccc
Sample Output 2
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)的更多相关文章
- 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 ...
- AtCoder Beginner Contest 045 C - たくさんの数式 / Many Formulas
Time limit : 2sec / Memory limit : 256MB Score : 300 points Problem Statement You are given a string ...
- AtCoder Beginner Contest 053 ABCD题
A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...
- AtCoder Beginner Contest 153 题解
目录 AtCoder Beginner Contest 153 题解 A - Serval vs Monster 题意 做法 程序 B - Common Raccoon vs Monster 题意 做 ...
- AtCoder Beginner Contest 173 题解
AtCoder Beginner Contest 173 题解 目录 AtCoder Beginner Contest 173 题解 A - Payment B - Judge Status Summ ...
- AtCoder Beginner Contest 172 题解
AtCoder Beginner Contest 172 题解 目录 AtCoder Beginner Contest 172 题解 A - Calc B - Minor Change C - Tsu ...
- AtCoder Beginner Contest 148 题解
目录 AtCoder Beginner Contest 148 题解 前言 A - Round One 题意 做法 程序 B - Strings with the Same Length 题意 做法 ...
- AtCoder Beginner Contest 238 A - F 题解
AtCoder Beginner Contest 238 \(A - F\) 题解 A - Exponential or Quadratic 题意 判断 \(2^n > n^2\)是否成立? S ...
- AtCoder Beginner Contest 100 2018/06/16
A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...
随机推荐
- mysql连接池不能回避的wait timeout问题(转)
起因 我们的项目组一直在使用albianj作为开发框架在开发应用.使用至今倒也是没有出现很大的问题,但最近加过监控的接口基本上都会在使用一段时间后,突然之间执行数据库操作变得很慢.虽然会变慢,但持续的 ...
- Delphi INI文件保存与读取
//需要引用IniFiles uses system.IniFiles; //保存INI配置文件 procedure TForm1.btnSaveClick(Sender: TObject); var ...
- 前端框架之Vue(3)-计算属性
计算属性 模板内的表达式非常便利,但是设计它们的初衷是用于简单运算的.在模板中放入太多的逻辑会让模板过重且难以维护.例如: <div id="example"> {{ ...
- [py]Python locals() 函数
Python locals() 函数作用 http://www.runoob.com/python/python-func-locals.html locals() 函数会以字典类型返回当前位置的全部 ...
- MySQL 基础 事务
什么是mysql的事务 MySQL 事务主要用于处理操作量大,复杂度高的数据.简单的说,事务就是一连串的DML的sql语句组合在一起,所以语句执行成功才算成功,如果有语句执行失败,执行就不成功 .比如 ...
- Linux下的python等操作【转载】
转自:https://blog.csdn.net/healthy_coder/article/details/50546384 https://blog.csdn.net/boyun58/articl ...
- MySql语句常用命令整理---多表查询
首先第一张表还是我们单表查询之前用到t_employee,我们在另外新建一个表t_dept(部门表)建表命令如下: drop table if exists t_dept; CREATE TABLE ...
- Java实现个人博客网站
说明:该项目是实验楼用户"LOU3165780622"发布在实验楼上的项目教程:[Java实现个人博客],未经允许,禁止转载: 该项目利用 SSM 框架和 Mysql 以及一些简单 ...
- 26-Python3 面向对象
26-Python3 面向对象 ''' 面向对象技术简介 ''' ''' 类定义 ''' ''' 类对象 ''' class MyClass: i = 12345 def f(self): retur ...
- [转]kafka介绍
转自 https://www.cnblogs.com/hei12138/p/7805475.html kafka介绍 1.1. 主要功能 根据官网的介绍,ApacheKafka®是一个分布式流媒体平台 ...