結果

問題 No.351 市松スライドパズル
ユーザー hogeover30
提出日時 2017-06-17 01:52:39
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 139 ms / 2,000 ms
コード長 725 bytes
コンパイル時間 687 ms
コンパイル使用メモリ 76,920 KB
最終ジャッジ日時 2025-01-05 00:44:19
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#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