結果

問題 No.264 じゃんけん
ユーザー iodo_shibaiodo_shiba
提出日時 2018-08-08 12:42:55
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,870 bytes
コンパイル時間 533 ms
コンパイル使用メモリ 56,628 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 06:21:34
合計ジャッジ時間 1,110 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<sstream>
#include<string>

enum class RPS{
    rock=0,
    scissors=1,
    paper=2
};
enum class RPSResult{
    Won=0,
    Drew=1,
    Lost=2
};

int main(){
    int in1,in2;
    RPS mine,yours;
    std::cin >> in1 >> in2;
    mine=static_cast<RPS>(in1);
    yours=static_cast<RPS>(in2);
    RPSResult res=RPSResult::Won;
    switch(mine){
        case RPS::rock:
            switch(yours){
                case RPS::rock:
                    res = RPSResult::Drew;
                    break;
                case RPS::scissors:
                    res = RPSResult::Won;
                    break;
                case RPS::paper:
                    res = RPSResult::Lost;
                    break;
            }
        break;
        case RPS::scissors:
            switch(yours){
                case RPS::rock:
                    res = RPSResult::Lost;
                    break;
                case RPS::scissors:
                    res = RPSResult::Drew;
                    break;
                case RPS::paper:
                    res = RPSResult::Won;
                    break;
            }
        break;
        case RPS::paper:
            switch(yours){
                case RPS::rock:
                    res = RPSResult::Won;
                    break;
                case RPS::scissors:
                    res = RPSResult::Lost;
                    break;
                case RPS::paper:
                    res = RPSResult::Drew;
                    break;
            }
        break;
    }
    switch(res){
        case RPSResult::Won:
            std::cout << "Won" << std::endl;
            break;
        case RPSResult::Drew:
            std::cout << "Drew" << std::endl;
            break;
        case RPSResult::Lost:
            std::cout << "Lost" << std::endl;
            break;
    }
    return 0;
}
0