結果

問題 No.769 UNOシミュレータ
ユーザー pekempeypekempey
提出日時 2018-12-17 04:17:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 847 bytes
コンパイル時間 384 ms
コンパイル使用メモリ 31,360 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-02 00:10:50
合計ジャッジ時間 1,691 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 3 ms
6,940 KB
testcase_12 AC 12 ms
6,940 KB
testcase_13 AC 11 ms
6,944 KB
testcase_14 AC 10 ms
6,944 KB
testcase_15 AC 20 ms
6,940 KB
testcase_16 AC 20 ms
6,944 KB
testcase_17 AC 19 ms
6,940 KB
testcase_18 AC 27 ms
6,944 KB
testcase_19 AC 28 ms
6,940 KB
testcase_20 AC 29 ms
6,940 KB
testcase_21 AC 29 ms
6,944 KB
testcase_22 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int a[100000];

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    int i = 0;
    int j = -1;
    int d = 1;
    int two = 0;
    int four = 0;
    while (m--) {
        char c[10];
        scanf("%s", c);
        if (two > 0 && c[4] != 't') {
            a[i] -= two;
            i = (i + d + n) % n;
            two = 0;
        }
        if (four > 0 && c[4] != 'f') {
            a[i] -= four;
            i = (i + d + n) % n;
            four = 0;
        }
        j = i;
        a[i]++;
        if (c[0] == 'r') {
            d *= -1;
        } else if (c[0] == 's') {
            i = (i + d + n) % n;
        } else if (c[4] == 't') {
            two += 2;
        } else if (c[4] == 'f') {
            four += 4;
        }
        i = (i + d + n) % n;
    }
    printf("%d %d\n", j + 1, a[j]);
    return 0;
}
0