結果

問題 No.769 UNOシミュレータ
ユーザー rogi52rogi52
提出日時 2022-10-07 16:27:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,594 bytes
コンパイル時間 3,206 ms
コンパイル使用メモリ 202,800 KB
実行使用メモリ 15,004 KB
最終ジャッジ日時 2023-09-02 16:49:44
合計ジャッジ時間 4,769 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 16 ms
6,960 KB
testcase_13 AC 18 ms
6,880 KB
testcase_14 AC 17 ms
6,884 KB
testcase_15 AC 31 ms
10,548 KB
testcase_16 AC 30 ms
10,616 KB
testcase_17 WA -
testcase_18 AC 44 ms
14,932 KB
testcase_19 AC 43 ms
15,004 KB
testcase_20 AC 45 ms
14,924 KB
testcase_21 AC 44 ms
14,924 KB
testcase_22 AC 2 ms
4,376 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 = 4;
            while(p + 1 < M && card[p + 1] == "drawfour") {
                id = (id + sgn + N) % N;
                cnt[id]++;
                p++;
                sum += 4;
            }
            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