Logo
(追記) (追記ここまで)

34452번 - Sequence 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB12111090.909%

문제

The board and card game Sequence is played with two standard decks of cards (not including Jokers or any special cards: only two of each suit, hearts, clubs, diamonds, and spades, consisting of cards 2ドル,ドル 3ドル,ドル 4ドル,ドル 5ドル,ドル 6ドル,ドル 7ドル,ドル 8ドル,ドル 9ドル,ドル 10ドル,ドル Jack, Queen, King and Ace) and a board with each of the cards on it, except for the Jacks. Tokens are placed on the board by each player to claim a spot as theirs.

Each card may only be played on one of its two corresponding spots on the board, and a token is placed on that spot. Each spot may only contain one token: so a card cannot be played on a particular spot on the board if there is already a token on that spot. The exception is the Jacks, since the Jacks are not represented on the board. The Jack of diamonds and clubs can be played anywhere where there is not already a token, and the Jack of hearts and spades can remove any token on the board.

Assume you have an empty starting board and are given an ordered list of moves made by the players. Each move contains information on which card was played, whether that card was used to place or remove a token, and which token on the board was placed or removed. Using this information, determine if there was an invalid move, or if the list of moves was valid.

입력

Input starts with a single integer on it's own line, $N$ (1ドル \le N \le 104$), which indicates the number of moves. The next $N$ lines contain four values, separated by spaces:

  • An integer 1ドル \le n \le N$ indicating the turn number. You are guaranteed that the turns will be given in input in order, and that each turn number is unique.
  • The card played, represented as two characters: a number or letter and a suit. The card number or letter is 2, 3, 4, 5, 6, 7, 8, 9, X (representing 10ドル$), J (representing Jack), Q (representing Queen), K (representing King), or A (representing Ace). The suit is a lowercase h (for hearts), c (for clubs), d (for diamonds), or
  • s (for spades). You are guaranteed that each card will be seen at most twice, as there are only two decks in play.
  • A character P or R indicating whether a token was placed or removed.
  • A card, in the same format as the card played, indicating where the token was placed or removed on the board. You are guaranteed that this card will not be a Jack, since Jacks are not on the board.

출력

If the list of moves is valid, output VALID GAME.

If the list of moves is invalid, output INVALID, followed by the first move number that makes it invalid.

제한

예제 입력 1

5
1 5s P 5s
2 7h P 7h
3 5s P 5s
4 Jh R 5s
5 Jd P 5s

예제 출력 1

VALID GAME

예제 입력 2

6
1 2h P 2h
2 Js R 3h
3 2h P 2h
4 3h P 2h
5 4h R Qd
6 Qd P Kd

예제 출력 2

INVALID 2

예제 입력 3

4
1 2s P 2s
2 Jd P 2s
3 2s P 2s
4 Jc P 3s

예제 출력 3

INVALID 3

예제 입력 4

4
1 6c P 6c
2 Jc R 6c
3 7h P 7h
4 9d P 9d

예제 출력 4

INVALID 2

노트

  • Input 1: This game is valid. On move 4ドル,ドル the Jack of hearts was used to remove the 5ドル$ of spades, so a card can be played on this token again using either a Jack of diamonds or a Jack of clubs.
  • Input 2: A Jack of spades is allowed to remove tokens, but there was never a token played on the 3ドル$ of hearts.
  • Input 3: Both 2ドル$ of spades on the board already have a token on them, so another 2ドル$ of spades cannot be played.
  • Input 4: The Jack of clubs is not allowed to remove tokens.

출처

School > CS@Mines > CS@Mines HSPC 2018 G번

  • 문제를 만든 사람: Jack Rosenthal
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /