結果

問題 No.264 じゃんけん
ユーザー koko_ukoko_u
提出日時 2015-10-05 00:18:40
言語 Java19
(openjdk 21)
結果
AC  
実行時間 55 ms / 5,000 ms
コード長 2,248 bytes
コンパイル時間 2,283 ms
コンパイル使用メモリ 79,832 KB
実行使用メモリ 50,224 KB
最終ジャッジ日時 2023-09-27 02:03:37
合計ジャッジ時間 3,599 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
49,848 KB
testcase_01 AC 55 ms
49,660 KB
testcase_02 AC 55 ms
49,952 KB
testcase_03 AC 55 ms
49,792 KB
testcase_04 AC 53 ms
49,936 KB
testcase_05 AC 53 ms
49,972 KB
testcase_06 AC 54 ms
50,224 KB
testcase_07 AC 55 ms
49,936 KB
testcase_08 AC 55 ms
50,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
        }
    }
}
0