結果

問題 No.769 UNOシミュレータ
ユーザー Mister
提出日時 2020-04-10 18:27:40
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 1,147 bytes
コンパイル時間 877 ms
コンパイル使用メモリ 72,940 KB
最終ジャッジ日時 2025-01-09 15:43:53
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>

void solve() {
    int n, m;
    std::cin >> n >> m;

    std::vector<int> cnt(n, 0);
    int id = -1, dir = 1;
    int two = 0, four = 0;
    bool skip = false, pass = false;

    std::string s;
    while (m--) {
        id += dir;

        if (skip) id += dir;
        skip = false;

        if (id < 0) id += n;
        if (id >= n) id -= n;

        if (!pass) std::cin >> s;
        pass = false;

        if (s != "drawtwo" && two > 0) {
            cnt[id] -= two;
            two = 0;

            pass = true;
            ++m;
            continue;
        }

        if (s != "drawfour" && four > 0) {
            cnt[id] -= four;
            four = 0;

            pass = true;
            ++m;
            continue;
        }

        ++cnt[id];

        if (s == "drawtwo") two += 2;
        if (s == "drawfour") four += 4;
        if (s == "skip") skip = true;
        if (s == "reverse") dir = -dir;
    }

    std::cout << id + 1 << " " << cnt[id] << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0