結果
| 問題 |
No.769 UNOシミュレータ
|
| コンテスト | |
| ユーザー |
greentea011
|
| 提出日時 | 2019-03-14 11:42:07 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,495 bytes |
| コンパイル時間 | 1,878 ms |
| コンパイル使用メモリ | 86,032 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-22 09:16:48 |
| 合計ジャッジ時間 | 2,881 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / 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=1;
};
void next() {
now = (now+n+rvflg)%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;} },
};
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()));
}
greentea011