結果

問題 No.351 市松スライドパズル
コンテスト
ユーザー Hachimori
提出日時 2016-03-11 23:14:14
言語 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
結果
AC  
実行時間 195 ms / 2,000 ms
コード長 654 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 314 ms
コンパイル使用メモリ 71,296 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2026-04-12 06:18:57
合計ジャッジ時間 3,495 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<iostream>
using namespace std;
const int BUF = 1000005;

int row, col;
int nRcIdx;
char rc[BUF];
int idx[BUF];

void read() {
    cin >> row >> col;
    cin >> nRcIdx;
    for (int i = 0; i < nRcIdx; ++i) {
        cin >> rc[i] >> idx[i];
    }
}


void work() {
    int r = 0;
    int c = 0;
    for (int i = nRcIdx - 1; i >= 0; --i) {
        if (rc[i] == 'R' && r == idx[i]) {
            c = (c + col - 1) % col;
        }
        else if (rc[i] == 'C' && c == idx[i]) {
            r = (r + row - 1) % row;
        }
    }
    cout << ((r + c) % 2 == 0 ? "white" : "black") << endl;
}


int main() {
    read();
    work();
    return 0;
}
0