#d2453. 德州扑克牌型判定

德州扑克牌型判定

Texas Hold'em Poker Hand Evaluation

Problem Description

Given the rank and suit of 55 playing cards, determine the strongest poker hand these 55 cards can form.

To guarantee a valid input, the following are assumed:

  1. All cards come from the same standard deck of playing cards;
  2. The input ranks are given in non-decreasing order;
  3. Suits have no ordering among themselves.

The hand types (from strongest to weakest) are defined as follows:

  1. ROYAL FLUSH: five cards with consecutively increasing ranks, all of the same suit, and whose highest card is an AA (Ace);
  2. STRAIGHT FLUSH: five cards with consecutively increasing ranks, all of the same suit;
  3. FOUR OF A KIND: at least four cards share the same rank;
  4. FULL HOUSE: at least three cards share the same rank, and the remaining two cards also share the same rank;
  5. FLUSH: all five cards are of the same suit;
  6. STRAIGHT: five cards with consecutively increasing ranks, not requiring the same suit;
  7. If the strongest possible hand is no better than THREE OF A KIND, output FOLD (fold).

Mapping between ranks and input numbers:

  • 2∼102\sim 10 correspond to 2∼102\sim 10;
  • JJ (Jack) corresponds to 1111, QQ (Queen) corresponds to 1212, KK (King) corresponds to 1313, AA (Ace) corresponds to 1414.

Mapping between suits and input numbers:

  • Spades correspond to 11;
  • Diamonds correspond to 22;
  • Hearts correspond to 33;
  • Clubs correspond to 44.

Input Format

Two lines, each containing 55 integers. The ii-th number in the first line is the rank of the ii-th card (guaranteed non-decreasing); the ii-th number in the second line is the suit of the ii-th card (guaranteed valid).

Output Format

Output the strongest hand these five cards can form, which is one of: ROYAL FLUSH, STRAIGHT FLUSH, FOUR OF A KIND, FULL HOUSE, FLUSH, STRAIGHT, FOLD (without quotes).

Sample Input 1

10 11 12 13 14
1 1 1 1 1

Sample Output 1

ROYAL FLUSH

Sample Input 2

10 11 12 13 14
1 2 1 3 4

Sample Output 2

STRAIGHT

Sample Input 3

6 6 6 7 7
1 2 3 1 3

Sample Output 3

FULL HOUSE

Sample Input 4

3 3 6 6 9
1 2 1 2 1

Sample Output 4

FOLD