結果

問題 No.769 UNOシミュレータ
ユーザー kk
提出日時 2020-08-26 21:32:07
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 1,619 bytes
コンパイル時間 1,885 ms
コンパイル使用メモリ 199,164 KB
実行使用メモリ 13,568 KB
最終ジャッジ日時 2024-04-25 03:49:43
合計ジャッジ時間 3,037 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 11 ms
6,400 KB
testcase_13 AC 11 ms
6,400 KB
testcase_14 AC 11 ms
6,400 KB
testcase_15 AC 20 ms
9,856 KB
testcase_16 AC 20 ms
9,984 KB
testcase_17 AC 20 ms
9,984 KB
testcase_18 AC 30 ms
13,568 KB
testcase_19 AC 33 ms
13,440 KB
testcase_20 AC 31 ms
13,440 KB
testcase_21 AC 31 ms
13,440 KB
testcase_22 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)
#define ALL(x) (x).begin(), (x).end()

const double PI = acos(-1);

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

  int n, m;
  cin >> n >> m;

  vector<string> line(m);
  REP (i, m) cin >> line[i];
  
  int cur = 0;
  vector<int> in(n), out(n);
  int dir = 1;
  int winner = -1;
  
  for (int i = 0; i < m; ) {
    string l = line[i];
    if (l == "number") {
      winner = cur;
      out[cur]++;
      cur += dir;
      cur = (cur % n + n) % n;
      ++i;
    } else if (l == "drawtwo") {
      int cnt = 0;
      int j;
      for (j = i; j < m && line[j] == l; j++) {
        ++cnt;
        winner = cur;
        out[cur]++;
        cur += dir;
        cur = (cur % n + n) % n;
      }
      in[cur] += 2 * cnt;
      cur += dir;
      cur = (cur % n + n) % n;
      i = j;
    } else if (l == "drawfour") {
      int cnt = 0;
      int j;
      for (j = i; j < m && line[j] == l; j++) {
        ++cnt;
        winner = cur;
        out[cur]++;
        cur += dir;
        cur = (cur % n + n) % n;
      }
      in[cur] += 4 * cnt;
      cur += dir;
      cur = (cur % n + n) % n;
      i = j;
    } else if (l == "skip") {
      winner = cur;
      out[cur]++;
      cur += 2 * dir;
      cur = (cur % n + n) % n;
      ++i;
    } else {
      winner = cur;
      out[cur]++;
      dir *= -1;
      cur += dir;
      cur = (cur % n + n) % n;
      ++i;
    }
  }
  
  cout << winner + 1 << " " << out[winner] - in[winner] << endl;
  
  return 0;
}
0