zoukankan      html  css  js  c++  java
  • AtCoder Beginner Contest 045 B

    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=55;
    const int mod=1e9+7;
    char A[101],B[101],C[101];
    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=1,a=b=c=-1;
            while(1){
                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==1){
                    a++;
                    tmp=A[a]-'a'+1;
                }
                else if(tmp==2){
                    b++;
                    tmp=B[b]-'a'+1;
    
                }
                else if(tmp==3){
                    c++;
                    tmp=C[c]-'a'+1;
                }
            }
        }
        return 0;
    }
  • 相关阅读:
    我用微笑剪辑我的微电影 ---六月实习总结
    【Espruino】NO.17 使用平板电脑调试Espruino(OTG方式)
    级联下拉列表
    GG中obey命令的使用
    Android Studio 怎样打开两个项目?
    解决在sdk manager中更新文件后出现This Android SDK requires Android Developer Toolkit version 23.1的错误
    UVA1492
    Codeforces Round #256 (Div. 2)A-D
    C++ bool和string转换
    云计算设计模式(十六)——优先级队列模式
  • 原文地址:https://www.cnblogs.com/shixinzei/p/7289545.html
Copyright © 2011-2022 走看看