結果

問題 No.351 市松スライドパズル
ユーザー roarisroaris
提出日時 2019-12-20 00:19:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 616 bytes
コンパイル時間 2,121 ms
コンパイル使用メモリ 165,384 KB
実行使用メモリ 8,396 KB
最終ジャッジ日時 2023-09-21 07:50:57
合計ジャッジ時間 5,121 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
8,228 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 92 ms
8,188 KB
testcase_14 AC 93 ms
8,164 KB
testcase_15 AC 94 ms
8,292 KB
testcase_16 AC 95 ms
8,256 KB
testcase_17 AC 89 ms
8,232 KB
testcase_18 AC 87 ms
8,232 KB
testcase_19 AC 93 ms
8,228 KB
testcase_20 AC 94 ms
8,396 KB
権限があれば一括ダウンロードができます

ソースコード

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