結果

問題 No.769 UNOシミュレータ
ユーザー rogi52rogi52
提出日時 2022-10-07 16:23:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,594 bytes
コンパイル時間 2,246 ms
コンパイル使用メモリ 205,352 KB
実行使用メモリ 15,376 KB
最終ジャッジ日時 2024-06-11 23:20:15
合計ジャッジ時間 3,513 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 3 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 WA -
testcase_10 AC 4 ms
6,940 KB
testcase_11 AC 4 ms
6,940 KB
testcase_12 WA -
testcase_13 AC 16 ms
7,168 KB
testcase_14 AC 16 ms
7,040 KB
testcase_15 WA -
testcase_16 AC 29 ms
10,896 KB
testcase_17 WA -
testcase_18 AC 40 ms
15,244 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 42 ms
15,376 KB
testcase_22 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int N,M; cin >> N >> M;
    vector<string> card(M);
    rep(i,M) cin >> card[i];

    int id = 0, sgn = +1;
    vector<int> ids = {}, cnt(N, 0);
    rep(p,M) {
        ids.push_back(id);
        if(card[p] == "number") {
            cnt[id]++;
            id = (id + sgn + N) % N;
        }
        else if(card[p] == "drawtwo") {
            cnt[id]++;
            int sum = 2;
            while(p + 1 < M && card[p + 1] == "drawtwo") {
                id = (id + sgn + N) % N;
                cnt[id]++;
                p++;
                sum += 2;
            }
            id = (id + sgn + N) % N;
            cnt[id] -= sum;
            id = (id + sgn + N) % N;
        }
        else if(card[p] == "drawfour") {
            cnt[id]++;
            int sum = 2;
            while(p + 1 < M && card[p + 1] == "drawfour") {
                id = (id + sgn + N) % N;
                cnt[id]++;
                p++;
                sum += 2;
            }
            id = (id + sgn + N) % N;
            cnt[id] -= sum;
            id = (id + sgn + N) % N;
        }
        else if(card[p] == "skip") {
            cnt[id]++;
            id = (id + sgn + sgn + N) % N;
        }
        else if(card[p] == "reverse") {
            cnt[id]++;
            sgn *= -1;
            id = (id + sgn + N) % N;
        }
        else { assert(0); }
    }

    cout << ids.back() + 1 << " " << cnt[ids.back()] << endl;
}
0