結果
| 問題 | No.769 UNOシミュレータ | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2018-12-17 04:14:48 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 32 ms / 2,000 ms | 
| コード長 | 847 bytes | 
| コンパイル時間 | 447 ms | 
| コンパイル使用メモリ | 31,488 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-22 08:43:22 | 
| 合計ジャッジ時間 | 1,432 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
ソースコード
#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;
}
            
            
            
        