結果

問題 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,046 ms
コンパイル使用メモリ 204,516 KB
実行使用メモリ 15,184 KB
最終ジャッジ日時 2023-09-02 16:46:42
合計ジャッジ時間 3,986 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 WA -
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 WA -
testcase_13 AC 16 ms
6,888 KB
testcase_14 AC 16 ms
6,948 KB
testcase_15 WA -
testcase_16 AC 31 ms
10,620 KB
testcase_17 WA -
testcase_18 AC 45 ms
14,868 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 44 ms
14,872 KB
testcase_22 AC 1 ms
4,380 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