結果
| 問題 | No.769 UNOシミュレータ | 
| コンテスト | |
| ユーザー |  greentea011 | 
| 提出日時 | 2019-03-14 11:33:18 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 1,521 bytes | 
| コンパイル時間 | 904 ms | 
| コンパイル使用メモリ | 87,444 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-22 09:16:08 | 
| 合計ジャッジ時間 | 2,541 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 22 WA * 1 | 
ソースコード
#include <iostream>
#include <string>
#include <map>
#include <functional>
#include <stdio.h>
struct uno {
    int n;
    int *p;
    int now;
    int d2cnt;
    int d4cnt;
    int rvflg;
    void init(int player) {
        n = player;
        p = new int[n];
        for (int i=0;i<n;i++) p[i]=0;
        now=0;
        d2cnt=0;
        d4cnt=0;
        rvflg=0;
    };
    void next() {
        now = (rvflg==0)?((now+1)%n):((now+n-1)%n);
    };
    void f(const std::string& type) {
        static std::map<std::string, std::function<void ()>> table = {
            { "number",   [this](){p[now]++;} },
            { "drawtwo",  [this](){p[now]++;d2cnt+=2;} },
            { "drawfour", [this](){p[now]++;d4cnt+=4;} },
            { "skip",     [this](){p[now]++;next();} },
            { "reverse",  [this](){p[now]++;rvflg=(rvflg+1)%2;} },
        };
        if ((d2cnt!=0)&&(type!="drawtwo")) {
            p[now]-=d2cnt;
            d2cnt=0;
            next();
        }
        if ((d4cnt!=0)&&(type!="drawfour")) {
            p[now]-=d4cnt;
            d4cnt=0;
            next();
        }
        table[type]();
    };
    int getWinner() {return now;};
    int getCard(int player) {return p[player];};
};
int main() {
    int n,m;
    scanf("%d %d", &n, &m);
    struct uno Uno;
    Uno.init(n);
    for (int i=0;i<m;i++) {
        std::string s;
        std::cin >> s;
        Uno.f(s);
        if (i!=(m-1)) Uno.next();
    }
    printf("%d %d\n", Uno.getWinner()+1, Uno.getCard(Uno.getWinner()));
}
            
            
            
        