結果

問題 No.769 UNOシミュレータ
ユーザー shunyashunya
提出日時 2019-02-21 17:16:28
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 3,185 bytes
コンパイル時間 423 ms
コンパイル使用メモリ 28,800 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-02 00:28:03
合計ジャッジ時間 1,473 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>  // scanfとprintfを使うおまじない

int nextTern(int t, int N, int isAsc)
{
    if (isAsc == 1)
    {
        if (t == N)
        {
            t = 1;
        } else
        {
            t += 1;
        }
    } else
    {
        if (t == 1)
        {
            t = N;
        } else
        {
            t -= 1;
        }
    }
    return t;
}

int main(int argc, char *argv[]){
    int N, M, i;
    char S[11];
    int whosTern = 1;
    int isAsc = 0;
    int drowTwoCnt = 0;
    int drowFourCnt = 0;
    // 標準入力から読み込む(空白や改行で勝手に区切ってくれる)
    // 逆に空白込みの文字列を読み込む場合は別の方法で読む必要がある。
    scanf("%d%d", &N, &M);
    
    int hands[N];
    for (i=0; i<N; i++)
    {
        hands[i] = 0;
    }
    
    for (i=0; i<M; i++)
    {
        scanf("%s", S);
        nextTern(whosTern, N, isAsc);
        if (S == "number")
        {
            if (drowTwoCnt > 0)
            {
                hands[whosTern-1] -= 2*drowTwoCnt;
                nextTern(whosTern, N, isAsc);
                drowTwoCnt = 0;
            } else if (drowFourCnt > 0)
            {
                hands[whosTern-1] -= 4*drowFourCnt;
                nextTern(whosTern, N, isAsc);
                drowFourCnt = 0;
            }
            hands[whosTern-1] += 1;
        } else if (S == "skip")
        {
            if (drowTwoCnt > 0)
            {
                hands[whosTern-1] -= 2*drowTwoCnt;
                nextTern(whosTern, N, isAsc);
                drowTwoCnt = 0;
            } else if (drowFourCnt > 0)
            {
                hands[whosTern-1] -= 4*drowFourCnt;
                nextTern(whosTern, N, isAsc);
                drowFourCnt = 0;
            }
            hands[whosTern-1] += 1;
            nextTern(whosTern, N, isAsc);
        } else if (S == "reverse")
        {
            if (drowTwoCnt > 0)
            {
                hands[whosTern-1] -= 2*drowTwoCnt;
                nextTern(whosTern, N, isAsc);
                drowTwoCnt = 0;
            } else if (drowFourCnt > 0)
            {
                hands[whosTern-1] -= 4*drowFourCnt;
                nextTern(whosTern, N, isAsc);
                drowFourCnt = 0;
            }
            hands[whosTern-1] += 1;
            if (isAsc == 0)
            {
                isAsc = 1;
            } else 
            {
                isAsc = 0;
            }
        } else if (S == "drawtwo")
        {
            if (drowFourCnt > 0)
            {
                hands[whosTern-1] -= 4*drowFourCnt;
                nextTern(whosTern, N, isAsc);
                drowFourCnt = 0;
            }
            hands[whosTern-1] += 1;
            drowTwoCnt += 1;
        } else if (S == "drawfour")
        {
            if (drowTwoCnt > 0)
            {
                hands[whosTern-1] -= 2*drowTwoCnt;
                nextTern(whosTern, N, isAsc);
                drowTwoCnt = 0;
            }
            hands[whosTern-1] += 1;
            drowFourCnt += 1;
        }
    }

    // 標準出力に出力
    printf("%d %d\n", whosTern, hands[whosTern-1]);

    return 0;
}
0