結果

問題 No.351 市松スライドパズル
コンテスト
ユーザー hogeover30
提出日時 2017-06-17 01:52:39
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 725 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 742 ms
コンパイル使用メモリ 95,380 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2026-06-06 16:58:54
合計ジャッジ時間 3,905 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

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

    int h, w, n; cin>>h>>w>>n;
    vector<pair<char, int>> q(n);
    for(auto& e: q) {
        string s;
        int k;
        cin>>s>>k;
        e=make_pair(s[0], k);
    }
    reverse(begin(q), end(q));

    int r=0, c=0;
    for(auto& e: q) {
        int k=e.second;
        if (e.first=='R') {
            if (r==k) {
                --c;
                if (c<0) c+=w;
            }
        }
        else {
            if (c==k) {
                --r;
                if (r<0) r+=h;
            }
        }
    }
    cout<<((r+c)%2 ? "black" : "white")<<endl;
}
0