21326_Snap

2022-5-16 18:19| 发布者: Hocassian| 查看: 44| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505154820600-Problem List-采集的数据-后羿采集器.html

Pro.ID

21326

Title

Snap

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21326

AC

0

Submit

2

Ratio

0.00%

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    Snap is a 2-player card game. The deck of cards contains several of each type of card. Initially each player has one half of the deck, in some random sequence, face down in a pile, and plays them in sequence from top to bottom, placing each card face-up in another pile. When the face-down pile is exhausted, the face-up pile is turned over to become the face-down pile and play continues.

    The two players play their cards concurrently and synchronously. That is, each places a card face up at exactly the same time. If two cards turned up at the same time are the same type, each player calls "Snap!" and the player who calls first takes the other's face-up pile and places it on top of his or her own.

    Play proceeds until one player has all the cards. This player is the winner.

    Your job is to simulate a game of snap to determine whether it will end within 1000 turns and, if so, to determine the winner.

    输入

    Each type of card is denoted by a single letter or digit. The first line of input Jane's initial pile of cards, from top to bottom. The second line of input is John's initial pile. Jane and John start with the same number of cards; not more than 50 each.

    输出

    Description

    Snap is a 2-player card game. The deck of cards contains several of each type of card. Initially each player has one half of the deck, in some random sequence, face down in a pile, and plays them in sequence from top to bottom, placing each card face-up in another pile. When the face-down pile is exhausted, the face-up pile is turned over to become the face-down pile and play continues.

    The two players play their cards concurrently and synchronously. That is, each places a card face up at exactly the same time. If two cards turned up at the same time are the same type, each player calls "Snap!" and the player who calls first takes the other's face-up pile and places it on top of his or her own.

    Play proceeds until one player has all the cards. This player is the winner.

    Your job is to simulate a game of snap to determine whether it will end within 1000 turns and, if so, to determine the winner.

    Input

    Each type of card is denoted by a single letter or digit. The first line of input Jane's initial pile of cards, from top to bottom. The second line of input is John's initial pile. Jane and John start with the same number of cards; not more than 50 each.

    Output

    During play, whenever it comes time to call "Snap!" the builtin function "random" is used to determine who calls first: if the expression

      rand()/99%2                 { in C or C++ }

      random div 99 mod 2     { in Pascal; see note below }

    yields 0, Jane calls first; otherwise John calls first. Whenever Jane calls first, print "Snap! for Jane: " followed by Jane's face-up pile, from top to bottom. Whenever John calls first, print "Snap! for John: " followed by John's face-up pile. If the game ends, print "John wins." or "Jane wins.", whichever is appropriate. If the game does not end when each player has turned over 1000 cards, print "Keeps going and going ..."

    Sample Input

    ABCDA
    CBADC

    Sample Output

    Snap! for Jane: BCBA
    Snap! for Jane: DADCBCBA
    Snap! for John: CBAC
    Snap! for John: ADADCBAC
    John wins.

    Source

    样例输入

    ABCDA
    CBADC

    样例输出

    Snap! for Jane: BCBA
    Snap! for Jane: DADCBCBA
    Snap! for John: CBAC
    Snap! for John: ADADCBAC
    John wins.

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部