結果

問題 No.351 市松スライドパズル
ユーザー TatsunoTatsuno
提出日時 2016-03-12 00:01:19
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,367 bytes
コンパイル時間 1,446 ms
コンパイル使用メモリ 161,684 KB
実行使用メモリ 7,636 KB
最終ジャッジ日時 2023-10-25 06:09:34
合計ジャッジ時間 6,260 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 224 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using int64 = int64_t;
#define times(n, i) for (int i = 0; i < n; i++)
#define range(n, m, i) for (int i = n; i < m; i++)
#define upto(n, m, i) for (int i = n; i <= m; i++)
#define downto(n, m, i) for (int i = n; i >= m; i--)
#define foreach(xs, x) for (auto &x : xs)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) erase(unique(all(xs)), (xs).end())
int64 mod10e9_7 = 1000000007;

int main()
{
    int h, w, n;
    cin >> h >> w >> n;
    vector<int> d(h);
    times(h, y) {
        d[y] = 0;
        for (int i = (y + ((w+1)%2))%2; i < w; i += 2) {
            d[y] += 1 << i;
        }
    }
    times(n, i) {
        char c; int v;
        cin >> c >> v;
        if (c == 'R') {
            int b = d[v] & 1;
            d[v] >>= 1;
            d[v] += (b << (w-1));
        }
        else {
            v = w-1 - v;
            int b = (d[h-1] >> v) & 1;
            downto(h-1, 1, y) {
                if ((d[y] >> v) & 1 == 1)
                    d[y] -= (1 << v);
                d[y] += d[y-1] & (1 << v);
            }
            if ((d[0] >> v) & 1 == 1)
                d[0] -= (1 << v);
            d[0] += (b << v);
        }
    }
    cout << ((d[0] & (1 << (w-1))) == 0 ? "black" : "white") << endl;
    return 0;
}
0