結果
| 問題 |
No.264 じゃんけん
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-10-05 00:18:40 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 69 ms / 5,000 ms |
| コード長 | 2,248 bytes |
| コンパイル時間 | 2,536 ms |
| コンパイル使用メモリ | 79,144 KB |
| 実行使用メモリ | 50,684 KB |
| 最終ジャッジ日時 | 2024-07-19 19:36:27 |
| 合計ジャッジ時間 | 3,633 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 9 |
ソースコード
package jp.co.kokou.sample.no264;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) {
try (InputStreamReader is = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(is)) {
String[] inputs = br.readLine().split("\\s+");
Hand mine = Hand.of(Integer.parseInt(inputs[0]));
Hand yours = Hand.of(Integer.parseInt(inputs[1]));
System.out.println(Judge.of(mine, yours));
} catch (IOException e) {
}
}
private enum Hand {
GU(0), CH(1), PA(2);
private final int value;
private Hand(int value) {
this.value = value;
}
public static Hand of(int value) {
for (Hand hand : Hand.values()) {
if (hand.value == value) {
return hand;
}
}
throw new IndexOutOfBoundsException();
}
}
private enum Judge {
WON("Won"),
LOST("Lost"),
DREW("Drew");
private final String value;
private Judge(String value) {
this.value = value;
}
@Override
public String toString() {
return value;
}
public static Judge of(Hand mine, Hand yours) {
switch (mine) {
case GU:
switch (yours) {
case GU:
return DREW;
case CH:
return WON;
case PA:
return LOST;
}
case CH:
switch (yours) {
case GU:
return LOST;
case CH:
return DREW;
case PA:
return WON;
}
case PA:
switch (yours) {
case GU:
return WON;
case CH:
return LOST;
case PA:
return DREW;
}
}
throw new IllegalArgumentException();
}
}
}