結果

問題 No.351 市松スライドパズル
ユーザー tnakao0123tnakao0123
提出日時 2016-04-08 10:59:03
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 318 ms / 2,000 ms
コード長 994 bytes
コンパイル時間 771 ms
コンパイル使用メモリ 84,336 KB
実行使用メモリ 8,300 KB
最終ジャッジ日時 2024-09-25 03:00:41
合計ジャッジ時間 4,992 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 351.cc: No.351 市松スライドパズル - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000000;

/* typedef */

/* global variables */

char ops[MAX_N];
int ks[MAX_N];

/* subroutines */

/* main */

int main() {
  int h, w, n;
  cin >> h >> w >> n;

  for (int i = 0; i < n; i++) cin >> ops[i] >> ks[i];

  int x = 0, y = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (ops[i] == 'R') {
      if (ks[i] == y) x = (x + w - 1) % w;
    }
    else {
      if (ks[i] == x) y = (y + h - 1) % h;
    }
    //printf("%c %d: %d %d\n", ops[i], ks[i], x, y);
  }

  cout << (((x + y) & 1) ? "black" : "white") << endl;
  return 0;
}
0