結果
| 問題 |
No.227 簡単ポーカー
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-04-21 11:38:04 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,736 bytes |
| コンパイル時間 | 2,075 ms |
| コンパイル使用メモリ | 79,480 KB |
| 実行使用メモリ | 41,252 KB |
| 最終ジャッジ日時 | 2024-07-20 05:00:44 |
| 合計ジャッジ時間 | 4,408 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 WA * 4 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
List<Integer> cards = new ArrayList<>();
for (int i = 0; i < 5; i++) {
cards.add(Integer.parseInt(sc.next()));
}
if (isFullHouse(cards)) {
System.out.println("FULL HOUSE");
} else if (isThreeCard(cards)) {
System.out.println("THREE CARD");
} else if (isTwoPair(cards)) {
System.out.println("TWO PAIR");
} else if (isOnePair(cards)) {
System.out.println("ONE PAIR");
} else {
System.out.println("NO HANDS");
}
}
private static boolean isFullHouse(List<Integer> cards) {
Map<Integer, Integer> match = calcCards(cards);
return match.size() == 2 && match.containsValue(3);
}
private static boolean isThreeCard(List<Integer> cards) {
Map<Integer, Integer> match = calcCards(cards);
return match.containsValue(3);
}
private static boolean isTwoPair(List<Integer> cards) {
Map<Integer, Integer> match = calcCards(cards);
return match.size() == 3 && !match.containsValue(3);
}
private static boolean isOnePair(List<Integer> cards) {
Map<Integer, Integer> match = calcCards(cards);
return match.size() == 4;
}
private static Map<Integer, Integer> calcCards(List<Integer> cards) {
Map<Integer, Integer> match = new HashMap<>();
for (Integer card : cards) {
if (!match.containsKey(card)) {
match.put(card, 0);
}
match.put(card, match.get(card) + 1);
}
return match;
}
}