結果

問題 No.769 UNOシミュレータ
ユーザー wonda_t_coffee
提出日時 2020-02-27 09:36:32
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,117 bytes
コンパイル時間 566 ms
コンパイル使用メモリ 60,380 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-22 09:34:14
合計ジャッジ時間 1,740 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;

int n, m;
int turn, dir;

void proceed() {
  turn = (turn + dir + n) % n;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> m;

  vector<int> put(n, 0), draw(n, 0);
  int d2 = 0, d4 = 0;
  turn = 0, dir = 1;

  string card;
  while (m-- > 0) {
    cin >> card;

    if (d2 && card == "drawtwo") {
      d2++;
      put[turn]++;
      proceed();
      continue;
    }

    if (d4 && card == "drawfour") {
      d4++;
      put[turn]++;
      proceed();
      continue;
    }

    if(d2) {
      draw[turn] += 2 * d2;
      d2 = 0;
      proceed();
    }

    if(d4) {
      draw[turn] += 4 * d4;
      d4 = 0;
      proceed();
    }

    put[turn]++;

    if (card == "drawtwo") {
      d2++;
    } else if (card == "drawfour") {
      d4++;
    } else if (card == "skip") {
      proceed();
    } else if (card == "reverse") {
      dir *= -1;
    } else if (card == "number") {
      // do nothing.
    }
    proceed();
  }

  turn = (turn - dir + n) % n;

  cout << turn + 1 << " " << put[turn] - draw[turn] << endl;

  return 0;
}
0