結果

問題 No.351 市松スライドパズル
ユーザー roarisroaris
提出日時 2019-12-20 00:19:48
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 616 bytes
コンパイル時間 1,595 ms
コンパイル使用メモリ 166,480 KB
実行使用メモリ 8,416 KB
最終ジャッジ日時 2024-07-07 02:15:45
合計ジャッジ時間 4,979 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    
    int H, W; cin >> H >> W;
    int N; cin >> N;
    char S[N];
    int K[N];
    
    for (int i=0; i<N; i++) cin >> S[i] >> K[i];
    
    int nx=0, ny=0;
    
    for (int i=N-1; i>=0; i--) {
        if (S[i]=='R' && K[i]==nx) {
            if (ny==0) ny = W-1;
            else ny -= 1;
        }
        else if (S[i]=='C' && K[i]==ny) {
            if (nx==0) nx = H-1;
            else nx -= 1;
        }
    }
    
    if ((nx+ny)%2==0) cout << "white" << endl;
    else cout << "black" << endl;
}
0