結果

問題 No.351 市松スライドパズル
コンテスト
ユーザー alpha_virginis
提出日時 2016-03-11 22:44:40
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 643 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 294 ms
コンパイル使用メモリ 69,848 KB
実行使用メモリ 9,116 KB
最終ジャッジ日時 2026-04-12 04:43:24
合計ジャッジ時間 2,399 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 12 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <cstdio>
#include <cstring>

#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <algorithm>

int H, W;
int N;
char S[1048576];
int K[1048576];

int main() {

  // step 1
  scanf("%d %d", &H, &W);
  scanf("%d", &N);
  for(int i = 0; i < N; ++i) {
    char t[2];
    scanf("%s %d", t, &K[i]);
    S[i] = t[0];
  }

  // step 2
  int r = 0, c = 0;
  for(int i = N - 1; i >= 0; --i) {
    if( S[i] == 'R' and r == K[i] ) {
      c = (c + 1) % W;
    }
    if( S[i] == 'C' and c == K[i] ) {
      r = (r + 1) % H;
    }
  }

  // step 3
  printf("%s\n", ((c + r) % 2 == 0 ? "white" : "black"));

  return 0;
}

0