結果

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

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
using namespace std;
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i))
int main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w; cin >> h >> w;
    int n; cin >> n;
    vector<char> s(n);
    vector<int> k(n);
    repeat (i,n) cin >> s[i] >> k[i];
    int y = 0, x = 0;
    repeat_reverse (i,n) {
        if (s[i] == 'R' and y == k[i]) {
            x = (x - 1 + w) % w;
        } else if (s[i] == 'C' and x == k[i]) {
            y = (y - 1 + h) % h;
        }
    }
    cout << (y % 2 == x % 2 ? "white" : "black") << endl;
    return 0;
}
0