QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#142933#6541. Make Everything WhiteSorahISAAC ✓101ms7664kbC++207.0kb2023-08-20 05:59:212023-08-20 05:59:24

Judging History

你现在查看的是最新测评结果

  • [2023-08-20 05:59:24]
  • 评测
  • 测评结果:AC
  • 用时:101ms
  • 内存:7664kb
  • [2023-08-20 05:59:21]
  • 提交

answer

#ifndef SorahISA
#define SorahISA
#include SorahISA __FILE__ SorahISA

void solve() {
    int N, M; cin >> N >> M;
    
    cout << 1 << "\n";
    vector<string> board(N);
    for (int i = 0; i < N; ++i) {
        cin >> board[i];
        for (int j = 0; j < M; ++j) {
            bool rev = (i == 0) xor (i == N-1) xor (j == 0) xor (j == M-1) xor (board[i][j] == 'B');
            cout << (rev ? 3 : 2);
        }
        cout << "\n";
    }
}

int32_t main() {
    fastIO();
    
    int t = 1; // cin >> t;
    for (int _ = 1; _ <= t; ++_) {
        // cout << "Case #" << _ << ": ";
        solve();
    }
    
    return 0;
}

#else

#ifdef local
#define _GLIBCXX_DEBUG 1
#endif
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define int int64_t
#define double __float80
using pii = pair<int, int>;
template <typename T> using Prior = std::priority_queue<T>;
template <typename T> using prior = std::priority_queue<T, vector<T>, greater<T>>;

// #define X first
// #define Y second
#define eb emplace_back
#define ef emplace_front
#define ee emplace
#define pb pop_back
#define pf pop_front
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
#define SZ(x) ((int)(x).size())

template <size_t D, typename T> struct Vec : vector<Vec<D-1, T>> {
    static_assert(D >= 1, "Vector dimension must be greater than zero!");
    template <typename... Args> Vec(int n = 0, Args... args) : vector<Vec<D-1, T>>(n, Vec<D-1, T>(args...)) {}
};

template <typename T> struct Vec<1, T> : vector<T> {
    Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {}
};

template <class F>
inline constexpr decltype(auto) lambda_fix(F&& f) {
    return [f = std::forward<F>(f)](auto&&... args) {
        return f(f, std::forward<decltype(args)>(args)...);
    };
}

#ifdef local
#define fastIO() void()
#define debug(...) \
    _color.emplace_back("\u001b[31m"), \
    fprintf(stderr, "%sAt [%s], line %d: (%s) = ", _color.back().c_str(), __FUNCTION__, __LINE__, #__VA_ARGS__), \
    _do(__VA_ARGS__), _color.pop_back(), \
    fprintf(stderr, "%s", _color.back().c_str())
deque<string> _color{"\u001b[0m"};

template <typename T> concept is_string = is_same_v<T, string&> or is_same_v<T, const string&>;
template <typename T> concept is_iterable = requires (T _t) {begin(_t);};

template <typename T> inline void _print_err(T &&_t);
template <typename T> inline void _print_err(T &&_t) requires is_iterable<T> and (not is_string<T>);
template <size_t I = 0, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(const tuple<U...> &);
template <size_t I = 0, typename ...U> inline typename enable_if<I <  sizeof...(U), void>::type _print_err(const tuple<U...> &_t);
template <size_t I = 0, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(tuple<U...> &);
template <size_t I = 0, typename ...U> inline typename enable_if<I <  sizeof...(U), void>::type _print_err(tuple<U...> &_t);
template <typename T, typename U> ostream& operator << (ostream &os, const pair<T, U> &_tu);

inline void _do() {cerr << "\n";};
template <typename T> inline void _do(T &&_t) {_print_err(_t), cerr << "\n";}
template <typename T, typename ...U> inline void _do(T &&_t, U &&..._u) {_print_err(_t), cerr << ", ", _do(_u...);}
#else
#define fastIO() ios_base::sync_with_stdio(0), cin.tie(0)
#define debug(...) void()
#endif

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

inline int getRand(int L, int R) {
    if (L > R) swap(L, R);
    return (int)(rng() % ((uint64_t)R - L + 1) + L);
}

template <typename T, typename U> bool chmin(T &lhs, U rhs) {return lhs > rhs ? lhs = rhs, 1 : 0;}
template <typename T, typename U> bool chmax(T &lhs, U rhs) {return lhs < rhs ? lhs = rhs, 1 : 0;}

/// below are Fast I/O and _print_err templates ///

/*
/// Fast I/O by FHVirus ///
/// https://fhvirus.github.io/blog/2020/fhvirus-io/ ///

#include <unistd.h>

const int S = 65536;

int OP = 0;
char OB[S];

inline char RC() {
    static char buf[S], *p = buf, *q = buf;
    return p == q and (q = (p = buf) + read(0, buf, S)) == buf ? -1 : *p++;
}

inline int RI() {
    static char c;
    int a;
    while (((c = RC()) < '0' or c > '9') and c != '-' and c != -1);
    if (c == '-') {
        a = 0;
        while ((c = RC()) >= '0' and c <= '9') a *= 10, a -= c ^ '0';
    }
    else {
        a = c ^ '0';
        while ((c = RC()) >= '0' and c <= '9') a *= 10, a += c ^ '0';
    }
    return a;
}

inline void WI(int n, char c = '\n') {
    static char buf[20], p;
    if (n == 0) OB[OP++] = '0';
    p = 0;
    if (n < 0) {
        OB[OP++] = '-';
        while (n) buf[p++] = '0' - (n % 10), n /= 10;
    }
    else {
        while (n) buf[p++] = '0' + (n % 10), n /= 10;
    }
    for (--p; p >= 0; --p) OB[OP++] = buf[p];
    OB[OP++] = c;
    if (OP > S-20) write(1, OB, OP), OP = 0;
}

/// Fast I/O by FHVirus ///
/// https://fhvirus.github.io/blog/2020/fhvirus-io/ ///
*/

#ifdef local

template <typename T> inline void _print_err(T &&_t) {cerr << _t;}

template <typename T> inline void _print_err(T &&_t) requires is_iterable<T> and (not is_string<T>) {
    string _tmp_color = _color.back();
    ++_tmp_color[3], _color.emplace_back(_tmp_color);
    cerr << _color.back() << "[";
    for (bool _first = true; auto &_x : _t) {
        if (!_first) cerr << ", ";
        _print_err(_x), _first = false;
    }
    cerr << "]" << (_color.pop_back(), _color.back());
}

template <typename T, typename U> ostream& operator << (ostream &os, const pair<T, U> &_tu) {
    string _tmp_color = _color.back();
    ++_tmp_color[3], _color.emplace_back(_tmp_color);
    cerr << _color.back() << "(";
    _print_err(_tu.first), cerr << ", ", _print_err(_tu.second);
    cerr << ")" << (_color.pop_back(), _color.back());
    return os;
}

template <size_t I = 0, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(const tuple<U...> &) {
    cerr << ")" << (_color.pop_back(), _color.back());
}

template <size_t I = 0, typename ...U> inline typename enable_if<I <  sizeof...(U), void>::type _print_err(const tuple<U...> &_t) {
    if (!I) {
        string _tmp_color = _color.back();
        ++_tmp_color[3], _color.emplace_back(_tmp_color);
        cerr << _color.back();
    }
    cerr << (I ? ", " : "("), _print_err(get<I>(_t)), _print_err<I+1, U...>(_t);
}

template <size_t I = 0, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(tuple<U...> &) {
    cerr << ")" << (_color.pop_back(), _color.back());
}

template <size_t I = 0, typename ...U> inline typename enable_if<I <  sizeof...(U), void>::type _print_err(tuple<U...> &_t) {
    if (!I) {
        string _tmp_color = _color.back();
        ++_tmp_color[3], _color.emplace_back(_tmp_color);
        cerr << _color.back();
    }
    cerr << (I ? ", " : "("), _print_err(get<I>(_t)), _print_err<I+1, U...>(_t);
}

#endif

#endif

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3512kb

input:

2 3
WBW
BWB

output:

1
222
333

result:

ok ok

Test #2:

score: 0
Accepted
time: 1ms
memory: 3464kb

input:

1 1
B

output:

1
3

result:

ok ok

Test #3:

score: 0
Accepted
time: 0ms
memory: 3516kb

input:

1 3
BWB

output:

1
222

result:

ok ok

Test #4:

score: 0
Accepted
time: 1ms
memory: 3516kb

input:

3 1
B
B
B

output:

1
2
3
2

result:

ok ok

Test #5:

score: 0
Accepted
time: 1ms
memory: 3468kb

input:

1 10
BBWWWWWWBW

output:

1
2322222233

result:

ok ok

Test #6:

score: 0
Accepted
time: 1ms
memory: 3548kb

input:

2 9
WWWWBWWWB
BBWWBWWWW

output:

1
233323333
323323332

result:

ok ok

Test #7:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

3 8
BBBBBBBB
WBWBBWBB
BBWWWWBW

output:

1
32222223
33233232
32333322

result:

ok ok

Test #8:

score: 0
Accepted
time: 1ms
memory: 3556kb

input:

4 7
BWWWWWB
WWBWWWB
WBBWBWW
BBBBBWW

output:

1
3333333
3232222
3332323
3222232

result:

ok ok

Test #9:

score: 0
Accepted
time: 1ms
memory: 3516kb

input:

5 6
BWWBWB
WWBBBB
BWBWBB
BWBWBW
BBWWWB

output:

1
333233
323332
223232
223233
323333

result:

ok ok

Test #10:

score: 0
Accepted
time: 1ms
memory: 3444kb

input:

6 5
BBBBW
BBBWB
WBBBW
WBWBW
WWWWB
WWBBB

output:

1
32222
23322
33333
33233
32222
23223

result:

ok ok

Test #11:

score: 0
Accepted
time: 1ms
memory: 3532kb

input:

7 4
BWWW
WWBW
BBBW
WWWB
BBWB
BBWB
BBWB

output:

1
3332
3233
2333
3222
2322
2322
3233

result:

ok ok

Test #12:

score: 0
Accepted
time: 1ms
memory: 3520kb

input:

8 3
WWW
BWB
WBW
BBB
BBB
BBW
WBB
WWB

output:

1
232
222
333
232
232
233
332
233

result:

ok ok

Test #13:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

9 1
B
B
W
B
W
B
W
B
W

output:

1
2
3
2
3
2
3
2
3
3

result:

ok ok

Test #14:

score: 0
Accepted
time: 1ms
memory: 3460kb

input:

1 1000
BWWBWWWBWBBBWBBBWBBWBBBWBBBBBBBWWBBWWWWBWBBWBWBWBWBBWWBWBWBWWWWBWBBBBBWWBWBWBWWWBBBWBBWWBWBBBBBBWWWBWBBBWWWWWWBBWWWWBWBWBBWBWBWBBWBBWBBBWWBWBBBBWBWWBWWWBBWWWBBWBWBWBBWWWBBWBBWWWWWBBWBWBWBBWWWWWBWBBBBWBBWBWWWBBBWWBWWBBBWWWBWBBBBBWBWWWBWWWWWBBWWBWWBBWBWBWBBWBWWWBBBBBBBBWWBWBWWBBBWBWWBBWBWWWBBBB...

output:

1
2223222323332333233233323333333223322223233232323233223232322223233333223232322233323322323333332223233322222233222232323323232332332333223233332322322233222332323233222332332222233232323322222323333233232223332232233322232333332322232222233223223323232332322233333333223232233323223323222333332323...

result:

ok ok

Test #15:

score: 0
Accepted
time: 4ms
memory: 3568kb

input:

100 1000
WWBBWWBWWWBWBWBBBBWBBBWWWBBBBWWBWWWWBWWWWWWBWBBWBWBBWWBBWBWWBWBBWBWBBWBBBBWBBWWBBWBBBBBBBBWWBWWBBBBBBBBBBBBWWBBWWWWWWBBWWBWWWWBBWWWBWWBBWWWWWWWWBWBBWBBBBWWBWBWWBBBBWBWBWWWBBWBWWWBWWBBWWBBBBBBBWBBBWWWBBWBBBBBWWWWBWBWWWWBWWWBWWBBBWBBWBWBBWBBWWBWBWWBWWBWBWBBBWBBWWBWBBBWBWWBWWWWBBBWWWBWBBBWBWBB...

output:

1
2322332333232322223222333222233233332333333232232322332232332322323223222232233223222222223323322222222222233223333332233233332233323322333333332322322223323233222232323332232333233223322222223222333223222223333232333323332332223223232232233232332332323222322332322232332333322233323222323222222322...

result:

ok ok

Test #16:

score: 0
Accepted
time: 7ms
memory: 3740kb

input:

200 999
WWWWWBWBWBWBWWBWWBWWWWWWWBWBWBBBWBWBWWBBBWWBBBWWBBBWBWWWWWBWWWBBWBWBBWBBBBBWWWBWWBWWBWBWWBWWBBWWWBWBWWWWWWWWWBWBWBWWWWWBWWBBWWWWWWBBWBWWBWWBWBWWBBWWWBBWWWWBBWBBBWWWBWBBBBWBWWWBBWWBBBWBWWWWWWWBWBWBBWBBWBBWWWWWWBBWWBWWBWWBBWBWBWBWBWWWWBWBBBWWWWBBBWWWWWWWBWBWBWBBBBBWWWWBWBBWBWWBWBWWBBBBBBWWBBBW...

output:

1
2333323232323323323333333232322232323322233222332223233333233322323223222223332332332323323322333232333333333232323333323322333333223233233232332233322333322322233323222232333223322232333333323232232232233333322332332332232323232333323222333322233333332323232222233332322323323233222222332223322322...

result:

ok ok

Test #17:

score: 0
Accepted
time: 10ms
memory: 3800kb

input:

299 999
BBWBBWWBBBBWWBWWWBBWWBWBWBWWWWBBBBBWBBBWWWWWWBBBBWBBWWWBWBBWWWBWWWWBWWWWWWWBBBWWBWBWWBWBWBWWBBWBWWBWBWBWBWWBBWWBWWWBWBWBBBBWBBBWWWBBBBWWBWWWWBWWWWWWBWBBWBWBBWWBBWBWWBWBBWBWBBWBBBBWBBWWBBWBBBBBBBBWWBWWBBBBBBBBBBBBWWBBWWWWWWBBWWBWWWWBBWWWBWWBBWWWWWWWWBWBBWBBBBWWBWBWWBBBBWBWBWWWBBWBWWWBWWBBWWBB...

output:

1
3232233222233233322332323233332222232223333332222322333232233323333233333332223323233232323322323323232323322332333232322223222333222233233332333333232232322332232332322323223222232233223222222223323322222222222233223333332233233332233323322333333332322322223323233222232323332232333233223322222223...

result:

ok ok

Test #18:

score: 0
Accepted
time: 6ms
memory: 3872kb

input:

300 1000
BWWBWBWWBWBWWWBBWWWWBWWBWBWBBBBBWBBWWWWWBBWWWWBWWWWWWBWBWBWBBBBBWBBBBBWBWWWBBBBBBBWWBBWBWWWWBWBWBBBBWWWWWBWBBBWBWWWWWWWBWWWBBWWBWBBWBBBWBBWBWWWBWBWBBWBBWBWWBWBWWBBWBBWWBBWWWBBBBBWWBBWWBWWWWWWBBWWWWBBBWBBBBBWWBBBBBWBBWBBWBBBBBBWBWBWWBBWBWBWWBBWBBBBBBBWWWWBBWWBBBBWWWWBBBBBBBBBBBBBWWBBWWBWBWBB...

output:

1
3332323323233322333323323232222232233333223333233333323232322222322222323332222222332232333323232222333332322232333333323332233232232223223233323232232232332323322322332233322222332233233333322333322232222233222223223223222222323233223232332232222222333322332222333322222222222223322332323223233232...

result:

ok ok

Test #19:

score: 0
Accepted
time: 12ms
memory: 3912kb

input:

400 999
BBBBBWWBBBWWBWWWWWWWWBBBBWWBWBWBBWWBBBWBBBWBWBWWWWBWWWWWWBWBWWBBWWBWBWWWWWBBWWBWWBWWBWBBBBBWBWBBBBBWBBWBWBWWBBBWWWWWBBWWBWBWWBBBWWWBWBWWBWBWBBWWWBWWWBBWWWWBBBBWBWWBWBBWWBBBWBWBWWWBWBBBWBWBWBBWBBWWBBWWBBWBWBBBBWWWWBBBBBBBWBWBBBBBWBBWWBWBBWBWWWWBWBWBBBWBBWWBBBBWWWBWWBBBWWBWBWBWBWWWWBBBWBWWBBWB...

output:

1
3222233222332333333332222332323223322232223232333323333332323322332323333322332332332322222323222223223232332223333322332323322233323233232322333233322333322223233232233222323233323222323232232233223322323222233332222222323222223223323223233332323222322332222333233222332323232333322232332232223333...

result:

ok ok

Test #20:

score: 0
Accepted
time: 10ms
memory: 4080kb

input:

500 1000
WWWBBBBWBBWWBBBWWBBBWWBWWWWWBBWBBBWBBBWBBWWWBBBBBBBBWBWWBBBWWBBBBBBWWWWBBBWWBBBBWBWWBWWWWWWBBBWBBBBWWBBBWWWBWBBBBBWWBBWWWBBBBBWBBWWBWWBBBBWWWBWBWBWBBBWWWBBWWWWBBWWWWWWWWBBBBWBWWWBWWWBBWWBBWBWWWBBBWWWWBBWWWBBBBBBBBWWWWWBBWWBBBWBWBWWBWBBBBWWWBWWBBBBBBWBWBBBWWBBWWWWWWBBBBBWBWBBBBBWWWBWWBBWWWBB...

output:

1
2332222322332223322233233333223222322232233322222222323322233222222333322233222232332333333222322223322233323222223322333222223223323322223332323232223332233332233333333222232333233322332232333222333322333222222223333322332223232332322223332332222223232223322333333222223232222233323322333223223333...

result:

ok ok

Test #21:

score: 0
Accepted
time: 13ms
memory: 4252kb

input:

600 1000
WBBBBWBBWBBBBWBBBBWBBBBWBWWBBBWWBBWBBWWWWBBWBWWWBBBWBWBBBWWWBWWWBBWWWBWWWBBBWWBWWWWBWWBBWWWWBWBBBWBWWBWBWBBBBBWBWBWWBWWWWBBBWWBWBBBBBWBWBWBWWBBBBBBBBBWWWWWWBWBWBWBBWBWWBBWWBWBBWBBBWBWBBWBWWBBWBBWBBWWBBBWWBBBWWBWBBWWWBWWBBBBWBBWWBBBBBWBWBWBWBBBBBBWWWWWBBBBWBBBWBWWBBWWWBWBWBWBBWBBBBWBBWBBBWBW...

output:

1
2222232232222322223222232332223322322333322323332223232223332333223332333222332333323322333323222323323232222232323323333222332322222323232332222222223333332323232232332233232232223232232332232232233222332223323223332332222322332222232323232222223333322223222323322333232323223222232232223233323332...

result:

ok ok

Test #22:

score: 0
Accepted
time: 20ms
memory: 4292kb

input:

700 1000
BWBWBWWWBBBWBWWBBWBBWBBWWBWWBWBWBBWWBBBWWBBBBBWWBBWBWBBWWWWBBWBBWBBWBBBBBWWWBBBWWWBWWBWBBWWBBWWWBWWBWWWBWBWBWWBBBWBWBBWBWWBBWBWBWWWBWWWWBWBWWWWBWBBBWBWBWWWWBWBBBBWBBBWWWBWBWWBWWBBWBWWWBWBBWBBBBWBBWBBBWWWBBWBBWBBWWBWWBBBBWWWBBBBWWBBBWWBBWBBBWBWBWWBBBWBBBWWWBBWWWBWBWWBWWWWWWWBBWBWWWBBWBWWWBWB...

output:

1
3323233322232332232232233233232322332223322222332232322333322322322322222333222333233232233223332332333232323322232322323322323233323333232333323222323233332322223222333232332332232333232232222322322233322322322332332222333222233222332232223232332223222333223332323323333333223233322323332322332222...

result:

ok ok

Test #23:

score: 0
Accepted
time: 23ms
memory: 4468kb

input:

800 1000
BBWWBWWBWBBBBBBWWWBBBBWWWBWWBBBWBBBWBBWBWWBBBBWBBBWWBWWWWBBBBBWBWWWWBWWBBWBWWWBBWWBBWBBWWWBBWBWWWBWBBWBWBWBWBWWBWWWWBWWBWWBWWWBWWBBBWBBBBBWWBWBBWBBBWBBBBWBWBWWWBBWBBWWWWBBBWWWBWWBBBWWWWWWBWBWWBWBBBBBWWWBBWWBBWBBBBBBBBWWWWWBWBBWBBWBBBBBWWWWBBWBBBWWWWWBWBWBBBWBBWBWBBBWBBWWBBWBBWBBBWWWBWBBWBBW...

output:

1
3233233232222223332222333233222322232232332222322233233332222232333323322323332233223223332232333232232323232332333323323323332332223222223323223222322223232333223223333222333233222333333232332322222333223322322222222333332322322322222333322322233333232322232232322232233223223222333232232232232223...

result:

ok ok

Test #24:

score: 0
Accepted
time: 22ms
memory: 4444kb

input:

900 1000
BBBWBBBBBWBWBWBBBBWWBWBWBBBWBWWWWWBBWBBWWWWBBWWBBBBWWWWWBBWBWBBBBWBWWWBBBWWWWBBBWWBBBWWBWWBWWWWBBBWBBWWWWWWWBBWBBBBWBWBWWWBBBWBWBBWWWWWWBWWBBWBWBBWWWWWWBWWWWBWBBWWBWBBWBWWBWBWWWWWBBWWBWBBWBBBBBBBWBBBBWWBBWBBWBWWWWWBBBBBBWBWWWBBWBWBWWWWWWWBWBWWBBBBBBBWBWBBWBWWBBBWWWBWWBBWWWWWWBBBWBBWBWBBWWBB...

output:

1
3223222223232322223323232223233333223223333223322223333322323222232333222333322233222332332333322232233333332232222323233322232322333333233223232233333323333232233232232332323333322332322322222223222233223223233333222222323332232323333333232332222222323223233222333233223333332223223232233223223322...

result:

ok ok

Test #25:

score: 0
Accepted
time: 53ms
memory: 5260kb

input:

1000 2000
WBBWWWWBBBWWBWBWWBBBBBWBBBBBWWBWWWBBBWBWBBBWWBBBBBWWWWBBBWWWWBBBBBWBBBBBWBBWWBBBBBWWWBBBWWWBBWBWBWWWBBWBBWBWBBBBWWBBWBWWBWBBWBWBBBBWBWWBWBWWWBWBBWWWWWWWWWWWBBWWBBWWBBBBBWBBWWBWBBWBBWBBBWWWBWBWWBWBBWWBBWBWBWWBWWWBBBWBBBWWBWWWBBBWWBBBBBWBBBBWWBBBWBWWBWBBBWWWWBWBBBWWBBBBBBWBWBWBBWBWBBWBBBBBBW...

output:

1
2223333222332323322222322222332333222323222332222233332223333222223222223223322222333222333223232333223223232222332232332322323222232332323332322333333333332233223322222322332322322322233323233232233223232332333222322233233322233222223222233222323323222333323222332222223232322323223222222323323223...

result:

ok ok

Test #26:

score: 0
Accepted
time: 53ms
memory: 5784kb

input:

1200 1999
WWBWWBBWBWBWWBWBWBWBWBBWWWBWBBWWBWWBWWBWBWBWWBBWWBWWBWWWWWBWWWWBWWBWWWWWWWWWWWWWWBWBBBWBWWBBWWWBWWWWBBBBBBBBWBWBBWWBBWWWWBWWBWWBWBBWWBWWBBBWBWBBWBWBBBWBBWBBBBBBWWWWBWBBWWBBWWBBBWBBBBBWBBWWBBWBWBWWBWBWWWWWBWBWWBWWWBBBWWWWBBBWWBWBBWWWWBWWWWWBWBBBBBWBBWBBBBBWBBWWBWWWWBBWWWWBWWWWWBBBBWBBWBWWWW...

output:

1
2323322323233232323232233323223323323323232332233233233333233332332333333333333332322232332233323333222222223232233223333233233232233233222323223232223223222222333323223322332223222223223322323233232333332323323332223333222332322333323333323222223223222223223323333223333233333222232232333322222322...

result:

ok ok

Test #27:

score: 0
Accepted
time: 58ms
memory: 6108kb

input:

1299 1999
BBBWWWWWBWBWWBWBBWWBWWBWWBBBWBBBBBWBBBBWWBWBBBWBWWBWWWWWWBBBBWBBWWBBWBWWBBBBBBBBWBWWBBWBWBBBWWWBWBBBWWBBWBBBBBBBBWBWBWBBWBWBBWWWBWBBBWWBBBWBBBWWBBWWWWBWBBBBWBWWWWWBBBWWBWWBWWWBWBBWBBWBBWWBWBWBWBWWBBWBBBBWWWBWWBBBWBBWWBBWBWBBBBBWWBWBBWBBBBBBBBBWWBWWWWBBWWWWBWWWWBWWBBWWWBBBWBBBBWWBBBWBWBBWBW...

output:

1
3223333323233232233233233222322222322223323222323323333332222322332232332222222232332232322233323222332232222222232323223232233323222332223222332233332322223233333222332332333232232232233232323233223222233323322232233223232222233232232222222223323333223333233332332233322232222332223232232332222333...

result:

ok ok

Test #28:

score: 0
Accepted
time: 61ms
memory: 6060kb

input:

1300 2000
WWBWBWBWWWBBBBWWBWBBWWBWBWWWWWBBBWBWWWWWWBBWBBBBWWWWBWBBWWBBBBWBWBBBBBBWWBWBBWBBBBWBWWBBWWWBWWBBBBWBWWBWWWWBWWWBWBBBBBBWBBBBBBBWWBWBWWBBWWWBBBBWWWWWWBBBBBBWBWWBBWWBWWBBBWWBBWBWWBWBWWWBBWBWBBBWBWWBWBBWBBWBWWWBWWWWBBBWWBBWBWBBWWWBWWWBBBWWWBWBWWWBWBBWWBBWBBWBBWWBWBWBWBWBBWWBBWWBWWWBWWWWBBWBWW...

output:

1
2323232333222233232233232333332223233333322322223333232233222232322222233232232222323322333233222232332333323332322222232222222332323322333222233333322222232332233233222332232332323332232322232332322322323332333322233223232233323332223332323332322332232232233232323232233223323332333322323332333333...

result:

ok ok

Test #29:

score: 0
Accepted
time: 60ms
memory: 6328kb

input:

1400 1999
WWWWBWWBWWBWBWBBBWBBWWBBWBWWWWWWBBBBBBBBWWWBWWBWBBBWBWBWBBWBWWWWBWBWWBWWWBWWWBWWWBWWBBBWBBBBWBBWWWBWWWWWWBBWWWBWBWBBWBWBWWWWWWBWWWBBBWBBBWBBBBWBWWBBWBWBWBBWBBWBBWWBWBBBWBBBBWBBWBWWBBBWWBWBBWWWBWBWWBBWBBWWWBBWBBWWBWWBWWBBWWBBWBWWBWBBWBWWBBBBBWBBWBWWWWBWWBWWBWBBBBWWWBBBBBBBBBBBBWWBBWBBBWBBWB...

output:

1
2333233233232322232233223233333322222222333233232223232322323333232332333233323332332223222232233323333332233323232232323333332333222322232222323322323232232232233232223222232232332223323223332323322322333223223323323322332232332322323322222322323333233233232222333222222222222332232223223223232322...

result:

ok ok

Test #30:

score: 0
Accepted
time: 71ms
memory: 6316kb

input:

1500 2000
WWBWBBWWBWWBWWBBWWWBBWWWBBWBWWBBBWBBWWWWBWWBBWWWWWBWBWBWBWWWWWWBBBBBWWWWBWWWBWBBWWBBBWBWBWBWWBWWWWBWWBWWWBWBBBWBBBWBBWBBBWBBBBBBBWWBBWWWWBWBBWBWBWBWBBWWBWBWBWWWWBWBBBBBWWBWBWBWWWBBBWBBWWBWBBBBBBWWWBWBBBWWWWWWBBWWWWBWBWBBWBWBWBBWBBWBBBWWBWBBBBWBWWBWWWBBWWWBBWBWBWBBWWWBBWBBWWWWWBBWBWBWBBWWWW...

output:

1
2323223323323322333223332232332223223333233223333323232323333332222233332333232233222323232332333323323332322232223223222322222223322333323223232323223323232333323222223323232333222322332322222233323222333333223333232322323232232232223323222232332333223332232323223332232233333223232322333332322223...

result:

ok ok

Test #31:

score: 0
Accepted
time: 73ms
memory: 6592kb

input:

1600 2000
BBBWBBBBWBWWWBWBBBWBWBWWWBWWBBWBBWWBWBBBBBWBBBWBWWBBWBBBBWBWWBBWBBWBWBBWBWBBWBBWWWWWBBWBWWBBWBBBWBBWWBBWWWWBWBBBWWBBWBBBBWBBBBWWBBBBWBBBWWBBWWWWWWBWWWWBBWBWWWWBWBWWBWWBBWWBWBBBWWBWBBWWBWWWBBBBWWBWWBWWWBWWWWWBBBBBBWWWBBWBWWBBWWWWBWBWBBBBBBWBWWBBBBWBBWBWWWWBWBWWWWBWBBBWBWWBBBWWWBWBWBWBWBBBWW...

output:

1
3223222232333232223232333233223223323222223222323322322223233223223232232322322333332232332232223223322333323222332232222322223322223222332233333323333223233332323323322332322233232233233322223323323332333332222223332232332233332323222222323322223223233332323333232223233222333232323232223323233223...

result:

ok ok

Test #32:

score: 0
Accepted
time: 90ms
memory: 6836kb

input:

1700 2000
BBWWWBBWBBWBBWBWWBBBBBWBBBWBBWWWBWWWWBWBWBWWBWWWBBBWBBWWWBBBBWWBWBBBBBWBWBWWBWWBWWWBBBBWBWBBWWBBWWWWWWBBWBBBBBWBBWBBWWBWBWBWBWBBBWWBWBWBWBBBWBBWBWBWWWWBBWWWWWBWWBBWWBWBWWBBWBBBBBBBWBWWBWWBBBWWWWWWBWBWWBBWBBBWBBWBBWWBBWBWBWWWBWBWWWBWWWBWWWBWBWBWBWBBBWWBWBBWWBWWBBBWWBBBWBBWWBWWWBBWBWWWBWWWWB...

output:

1
3233322322322323322222322232233323333232323323332223223332222332322222323233233233322223232233223333332232222232232233232323232223323232322232232323333223333323322332323322322222223233233222333333232332232223223223322323233323233323332333232323232223323223323322233222322332333223233323333233333222...

result:

ok ok

Test #33:

score: 0
Accepted
time: 95ms
memory: 7172kb

input:

1800 2000
BWBWWWBWWBBWBWWWBWBBWBBBBWWWBBBWBWWWBWBWWWWWWBWWBBWBWWBBWWWBBBBWWBWBBWBWBBBWWBWBWWBWBBWWWWBWWWWWWBWBWWWBBBWBWBBBWBWBWBWWBBBWWBBWWBBBBBBWWWWBWBWWWWWWBWBWBBWWBWWBWWWWWBWBWWBWWBBWBBBWWWBWWBWWBBBWBBWWWWBWBWBBBBBWBBBWWWWBWWWWWBBBBBWBBBBWBBBBWWWWWBWWWWWWWBWBBBWWWBBBBBBWBWWBBBWBBBWWWBWBWBBBWBWWBW...

output:

1
3323332332232333232232222333222323332323333332332232332233322223323223232223323233232233332333333232333222323222323232332223322332222223333232333333232322332332333332323323322322233323323322232233332323222223222333323333322222322223222233333233333332322233322222232332223222333232322232332323332322...

result:

ok ok

Test #34:

score: 0
Accepted
time: 101ms
memory: 7396kb

input:

1900 2000
BWBWBWBBWWWWWBWBWBBWBWBBWWWBWWWBBBBBBWWWBWWBWBBWBBBWWWBBBWBWBWWWBBBWWWBBBBBWWBBBWWWWWWWBBBBBBWBBBWWWWBBBBBWBBWWWWWWBWBWWBWBBWBWBWBWBBBWWWWBBBWBWWBWWWBBBWBWBWWBBBWBBBWWBWWBBWBBWWBWBBWWWWWBBWBBBWWBBWBWWBBBBBWWWWWWWBBBBWWWBWWBBWBWWWWWBWBBWWBWBBWBBWBWBWWBWWBBWWBWWWWBBBBBWWBWBWWWBBWWWWWWWBBBWWW...

output:

1
3323232233333232322323223332333222222333233232232223332223232333222333222223322233333332222223222333322222322333333232332322323232322233332223233233322232323322232223323322322332322333332232223322323322222333333322223332332232333332322332322322323233233223323333222223323233322333333322233333323222...

result:

ok ok

Test #35:

score: 0
Accepted
time: 95ms
memory: 7664kb

input:

2000 2000
BBBWBBBBWBWBWBBBWBBWWBWBWWBBBWBBWWWBWBWWBWBBBWBWWBWWWBWWBWBBWWBWBBBBWWBWBBBBBBWBBWBWBBWBBWWWBWBBBWBBWWBBWWBWWBWBBBBWBBWWBWWBBBWWWBBWBWWWWBBBWWBBBBWBBWWWWWBBWWBBWWBBWWWBBBBWWWWBWBWWWWBBWWWWWWBWBBBBBWBWWWWBBWWBWWBWWWBWBBBBBWBBWWWBWBWBWBBBBBBWBBWWBBWWWBWBWWBWWWBBWWWWBBWBBBBWWWWBWBBBWWBWWWWWBB...

output:

1
3223222232323222322332323322232233323233232223233233323323223323222233232222223223232232233323222322332233233232222322332332223332232333322233222232233333223322332233322223333232333322333333232222232333322332332333232222232233323232322222232233223332323323332233332232222333323222332333332232223233...

result:

ok ok

Test #36:

score: 0
Accepted
time: 1ms
memory: 3588kb

input:

2000 1
W
W
B
W
B
B
B
W
W
W
W
B
B
W
B
B
W
W
B
W
B
W
W
B
B
B
B
B
W
B
W
W
B
B
W
B
B
W
W
W
B
W
W
W
W
B
B
W
B
B
B
B
W
B
W
W
B
B
W
B
W
B
B
B
B
W
W
B
B
B
B
W
B
W
B
W
W
W
B
B
B
W
W
B
W
W
B
W
W
W
W
B
W
W
B
B
W
W
B
W
W
B
W
W
B
B
W
W
B
B
W
W
B
W
W
W
W
B
B
W
W
B
B
W
W
B
W
W
B
W
W
B
W
W
B
B
W
B
W
W
B
B
W
B
W
B
B...

output:

1
3
2
3
2
3
3
3
2
2
2
2
3
3
2
3
3
2
2
3
2
3
2
2
3
3
3
3
3
2
3
2
2
3
3
2
3
3
2
2
2
3
2
2
2
2
3
3
2
3
3
3
3
2
3
2
2
3
3
2
3
2
3
3
3
3
2
2
3
3
3
3
2
3
2
3
2
2
2
3
3
3
2
2
3
2
2
3
2
2
2
2
3
2
2
3
3
2
2
3
2
2
3
2
2
3
3
2
2
3
3
2
2
3
2
2
2
2
3
3
2
2
3
3
2
2
3
2
2
3
2
2
3
2
2
3
3
2
3
2
2
3
3
2
3
2
3
3
2
3
...

result:

ok ok