結果

問題 No.769 UNOシミュレータ
ユーザー pekempeypekempey
提出日時 2018-12-17 04:14:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 847 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 30,540 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-14 11:53:40
合計ジャッジ時間 1,729 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 10 ms
4,384 KB
testcase_13 AC 10 ms
4,380 KB
testcase_14 AC 10 ms
4,380 KB
testcase_15 AC 18 ms
4,384 KB
testcase_16 AC 19 ms
4,380 KB
testcase_17 AC 19 ms
4,380 KB
testcase_18 AC 27 ms
4,384 KB
testcase_19 AC 28 ms
4,384 KB
testcase_20 AC 28 ms
4,380 KB
testcase_21 AC 27 ms
4,380 KB
testcase_22 AC 2 ms
4,380 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