QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#309101#8130. Yet Another Balanced Coloring Problemucup-team112#AC ✓54ms12548kbC++2011.6kb2024-01-20 14:46:332024-10-14 18:04:47

Judging History

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

  • [2024-10-14 18:04:47]
  • 管理员手动重测本题所有获得100分的提交记录
  • 测评结果:AC
  • 用时:54ms
  • 内存:12548kb
  • [2024-03-18 02:37:14]
  • hack成功,自动添加数据
  • (/hack/577)
  • [2024-01-20 14:46:33]
  • 评测
  • 测评结果:100
  • 用时:34ms
  • 内存:28244kb
  • [2024-01-20 14:46:33]
  • 提交

answer

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

namespace templates {
// type
using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pil = pair<int, ll>;
using Pli = pair<ll, int>;
using Pll = pair<ll, ll>;
template <class T>
using pq = priority_queue<T>;
template <class T>
using qp = priority_queue<T, vector<T>, greater<T>>;
// clang-format off
#define vec(T, A, ...) vector<T> A(__VA_ARGS__);
#define vvec(T, A, h, ...) vector<vector<T>> A(h, vector<T>(__VA_ARGS__));
#define vvvec(T, A, h1, h2, ...) vector<vector<vector<T>>> A(h1, vector<vector<T>>(h2, vector<T>(__VA_ARGS__)));
// clang-format on

// for loop
#define fori1(a) for (ll _ = 0; _ < (a); _++)
#define fori2(i, a) for (ll i = 0; i < (a); i++)
#define fori3(i, a, b) for (ll i = (a); i < (b); i++)
#define fori4(i, a, b, c) for (ll i = (a); ((c) > 0 || i > (b)) && ((c) < 0 || i < (b)); i += (c))
#define overload4(a, b, c, d, e, ...) e
#define fori(...) overload4(__VA_ARGS__, fori4, fori3, fori2, fori1)(__VA_ARGS__)

// declare and input
// clang-format off
#define INT(...) int __VA_ARGS__; inp(__VA_ARGS__);
#define LL(...) ll __VA_ARGS__; inp(__VA_ARGS__);
#define STRING(...) string __VA_ARGS__; inp(__VA_ARGS__);
#define CHAR(...) char __VA_ARGS__; inp(__VA_ARGS__);
#define DOUBLE(...) double __VA_ARGS__; STRING(str___); __VA_ARGS__ = stod(str___);
#define VEC(T, A, n) vector<T> A(n); inp(A);
#define VVEC(T, A, n, m) vector<vector<T>> A(n, vector<T>(m)); inp(A);
// clang-format on

// const value
const ll MOD1   = 1000000007;
const ll MOD9   = 998244353;
const double PI = acos(-1);

// other macro
#ifndef RIN__LOCAL
#define endl "\n"
#endif
#define spa ' '
#define len(A) ll(A.size())
#define all(A) begin(A), end(A)

// function
vector<char> stoc(string &S) {
    int n = S.size();
    vector<char> ret(n);
    for (int i = 0; i < n; i++) ret[i] = S[i];
    return ret;
}
string ctos(vector<char> &S) {
    int n      = S.size();
    string ret = "";
    for (int i = 0; i < n; i++) ret += S[i];
    return ret;
}

template <class T>
auto min(const T &a) {
    return *min_element(all(a));
}
template <class T>
auto max(const T &a) {
    return *max_element(all(a));
}
template <class T, class S>
auto clamp(T &a, const S &l, const S &r) {
    return (a > r ? r : a < l ? l : a);
}
template <class T, class S>
inline bool chmax(T &a, const S &b) {
    return (a < b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chmin(T &a, const S &b) {
    return (a > b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chclamp(T &a, const S &l, const S &r) {
    auto b = clamp(a, l, r);
    return (a != b ? a = b, 1 : 0);
}

template <typename T>
T sum(vector<T> &A) {
    T tot = 0;
    for (auto a : A) tot += a;
    return tot;
}

template <typename T>
vector<T> compression(vector<T> X) {
    sort(all(X));
    X.erase(unique(all(X)), X.end());
    return X;
}

// input and output
namespace io {

// vector<T>
template <typename T>
istream &operator>>(istream &is, vector<T> &A) {
    for (auto &a : A) is >> a;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &A) {
    for (size_t i = 0; i < A.size(); i++) {
        os << A[i];
        if (i != A.size() - 1) os << ' ';
    }
    return os;
}

// vector<vector<T>>
template <typename T>
istream &operator>>(istream &is, vector<vector<T>> &A) {
    for (auto &a : A) is >> a;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<vector<T>> &A) {
    for (size_t i = 0; i < A.size(); i++) {
        os << A[i];
        if (i != A.size() - 1) os << endl;
    }
    return os;
}

// pair<S, T>
template <typename S, typename T>
istream &operator>>(istream &is, pair<S, T> &A) {
    is >> A.first >> A.second;
    return is;
}
template <typename S, typename T>
ostream &operator<<(ostream &os, pair<S, T> &A) {
    os << A.first << ' ' << A.second;
    return os;
}

// vector<pair<S, T>>
template <typename S, typename T>
istream &operator>>(istream &is, vector<pair<S, T>> &A) {
    for (size_t i = 0; i < A.size(); i++) {
        is >> A[i];
    }
    return is;
}
template <typename S, typename T>
ostream &operator<<(ostream &os, vector<pair<S, T>> &A) {
    for (size_t i = 0; i < A.size(); i++) {
        os << A[i];
        if (i != A.size() - 1) os << endl;
    }
    return os;
}

// tuple
template <typename T, size_t N>
struct TuplePrint {
    static ostream &print(ostream &os, const T &t) {
        TuplePrint<T, N - 1>::print(os, t);
        os << ' ' << get<N - 1>(t);
        return os;
    }
};
template <typename T>
struct TuplePrint<T, 1> {
    static ostream &print(ostream &os, const T &t) {
        os << get<0>(t);
        return os;
    }
};
template <typename... Args>
ostream &operator<<(ostream &os, const tuple<Args...> &t) {
    TuplePrint<decltype(t), sizeof...(Args)>::print(os, t);
    return os;
}

// io functions
void FLUSH() {
    cout << flush;
}

void print() {
    cout << endl;
}
template <class Head, class... Tail>
void print(Head &&head, Tail &&...tail) {
    cout << head;
    if (sizeof...(Tail)) cout << spa;
    print(std::forward<Tail>(tail)...);
}

template <typename T, typename S>
void prisep(vector<T> &A, S sep) {
    int n = A.size();
    for (int i = 0; i < n; i++) {
        cout << A[i];
        if (i != n - 1) cout << sep;
    }
    cout << endl;
}
template <typename T, typename S>
void priend(T A, S end) {
    cout << A << end;
}
template <typename T>
void prispa(T A) {
    priend(A, spa);
}
template <typename T, typename S>
bool printif(bool f, T A, S B) {
    if (f)
        print(A);
    else
        print(B);
    return f;
}

template <class... T>
void inp(T &...a) {
    (cin >> ... >> a);
}

} // namespace io
using namespace io;

// read graph
vector<vector<int>> read_edges(int n, int m, bool direct = false, int indexed = 1) {
    vector<vector<int>> edges(n, vector<int>());
    for (int i = 0; i < m; i++) {
        INT(u, v);
        u -= indexed;
        v -= indexed;
        edges[u].push_back(v);
        if (!direct) edges[v].push_back(u);
    }
    return edges;
}
vector<vector<int>> read_tree(int n, int indexed = 1) {
    return read_edges(n, n - 1, false, indexed);
}

template <typename T = long long>
vector<vector<pair<int, T>>> read_wedges(int n, int m, bool direct = false, int indexed = 1) {
    vector<vector<pair<int, T>>> edges(n, vector<pair<int, T>>());
    for (int i = 0; i < m; i++) {
        INT(u, v);
        T w;
        inp(w);
        u -= indexed;
        v -= indexed;
        edges[u].push_back({v, w});
        if (!direct) edges[v].push_back({u, w});
    }
    return edges;
}
template <typename T = long long>
vector<vector<pair<int, T>>> read_wtree(int n, int indexed = 1) {
    return read_wedges<T>(n, n - 1, false, indexed);
}

// yes / no
namespace yesno {

// yes
inline bool yes(bool f = true) {
    cout << (f ? "yes" : "no") << endl;
    return f;
}
inline bool Yes(bool f = true) {
    cout << (f ? "Yes" : "No") << endl;
    return f;
}
inline bool YES(bool f = true) {
    cout << (f ? "YES" : "NO") << endl;
    return f;
}

// no
inline bool no(bool f = true) {
    cout << (!f ? "yes" : "no") << endl;
    return f;
}
inline bool No(bool f = true) {
    cout << (!f ? "Yes" : "No") << endl;
    return f;
}
inline bool NO(bool f = true) {
    cout << (!f ? "YES" : "NO") << endl;
    return f;
}

// possible
inline bool possible(bool f = true) {
    cout << (f ? "possible" : "impossible") << endl;
    return f;
}
inline bool Possible(bool f = true) {
    cout << (f ? "Possible" : "Impossible") << endl;
    return f;
}
inline bool POSSIBLE(bool f = true) {
    cout << (f ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return f;
}

// impossible
inline bool impossible(bool f = true) {
    cout << (!f ? "possible" : "impossible") << endl;
    return f;
}
inline bool Impossible(bool f = true) {
    cout << (!f ? "Possible" : "Impossible") << endl;
    return f;
}
inline bool IMPOSSIBLE(bool f = true) {
    cout << (!f ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return f;
}

// Alice Bob
inline bool Alice(bool f = true) {
    cout << (f ? "Alice" : "Bob") << endl;
    return f;
}
inline bool Bob(bool f = true) {
    cout << (f ? "Bob" : "Alice") << endl;
    return f;
}

// Takahashi Aoki
inline bool Takahashi(bool f = true) {
    cout << (f ? "Takahashi" : "Aoki") << endl;
    return f;
}
inline bool Aoki(bool f = true) {
    cout << (f ? "Aoki" : "Takahashi") << endl;
    return f;
}

} // namespace yesno
using namespace yesno;

} // namespace templates
using namespace templates;

struct UnionFind {
    int n;
    std::vector<int> par;
    int group;

    UnionFind() = default;
    UnionFind(int n) : n(n) {
        par.assign(n, -1);
        group = n;
    }

    int find(int x) {
        if (par[x] < 0) return x;
        par[x] = find(par[x]);
        return par[x];
    }

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (par[x] > par[y]) std::swap(x, y);
        group--;
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return -par[find(x)];
    }

    std::vector<int> roots() {
        std::vector<int> ret;
        for (int i = 0; i < n; i++) {
            if (i == find(i)) ret.push_back(i);
        }
        return ret;
    }

    bool isroot(int x) {
        return x == find(x);
    }
};

void solve() {
    INT(n, m);
    VEC(int, P, n - 1);
    VEC(int, Q, m - 1);
    int k = min(P) - 1;

    UnionFind UF(2 * k);
    auto dfs = [&](auto &&self, int pos, vector<vector<int>> &edges) -> int {
        if (pos < k) return pos;
        int res = -1;
        for (auto npos : edges[pos]) {
            auto nex = self(self, npos, edges);
            if (nex == -1) {
            } else if (res == -1) {
                res = nex;
            } else {
                UF.unite(2 * res, 2 * nex + 1);
                UF.unite(2 * res + 1, 2 * nex);
                res = -1;
            }
        }
        return res;
    };

    auto f = [&](int n, vector<int> &P) {
        vvec(int, child, n, 0);
        fori(i, n - 1) {
            child[P[i] - 1].push_back(i);
        }
        dfs(dfs, n - 1, child);
    };
    f(n, P);
    f(m, Q);

    vec(char, ans, k);
    fori(i, k) {
        int p = UF.find(2 * i);
        if (p % 2 == 0) {
            ans[i] = 'R';
        } else {
            ans[i] = 'B';
        }
    }
    prisep(ans, "");

#ifdef RIN__LOCAL
    {
        auto dfs = [&](auto &&self, int pos, vector<vector<int>> &edges) -> int {
            int tot = 0;
            for (auto npos : edges[pos]) {
                tot += self(self, npos, edges);
            }
            assert(abs(tot) <= 1);
            return tot;
        };
        auto check = [&](int n, vector<int> &P) {
            vvec(int, child, n, 0);
            fori(i, n - 1) {
                child[P[i] - 1].push_back(i);
            }
            dfs(dfs, n - 1, child);
        };

        check(n, P);
        check(m, Q);
    }
#endif
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    // cout << fixed << setprecision(12);
    int t;
    t = 1;
    cin >> t;
    while (t--) solve();
    return 0;
}

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

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3604kb

input:

2
7 7
5 5 6 6 7 7
5 6 5 6 7 7
5 4
4 4 5 5
4 4 4

output:

RBBR
RBR

result:

ok ok (2 test cases)

Test #2:

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

input:

10000
6 6
5 5 5 5 6
5 6 6 6 6
9 6
7 9 7 7 6 8 9 9
6 6 6 6 6
9 8
9 9 8 7 7 8 8 9
7 7 8 7 7 7 8
6 10
4 5 5 6 6
4 6 5 7 8 9 8 9 10
6 9
6 6 6 6 6
6 9 7 8 8 9 9 9
8 9
8 6 6 7 6 7 8
7 9 7 6 7 8 9 9
9 8
6 7 7 5 8 8 8 9
7 5 6 5 8 7 8
8 7
6 6 5 5 6 7 8
5 7 6 6 7 7
9 9
8 9 8 8 8 8 9 9
9 9 8 8 9 9 8 9
9 8
8 8 ...

output:

RBRB
RBBRR
RBRRBB
RRB
RBRBR
RRBRB
RRBB
RBRB
RBBRBRR
RBRBRBR
RBR
RBRBRB
RRB
RBRBRBR
BRRRBB
RBRB
RRB
RBRBR
RRB
RBRBR
BRRBB
BRRB
RBRBB
BRB
RBRBR
RRBB
RBRBBR
RRBRBB
RBBR
BRBRBR
RBBRBR
RBRBB
RBRBRB
RBRBRB
RRBBRB
RBR
RRBB
BRR
RRB
RBRBB
RBBR
BRBRBR
BBR
RRBRB
RBB
RBRBRB
BRRBBR
RRB
BRBRBR
RRB
RBB
RBRB
RBRBR
...

result:

ok ok (10000 test cases)

Test #3:

score: 0
Accepted
time: 17ms
memory: 3584kb

input:

1000
98 96
41 39 52 47 34 37 45 33 68 54 74 35 65 58 49 46 53 42 87 30 43 48 38 36 56 40 88 66 32 31 72 44 91 96 51 85 83 61 60 59 80 63 70 80 75 61 51 83 50 69 86 55 79 62 67 57 73 93 96 64 69 91 78 73 80 83 81 91 91 71 76 81 75 90 92 77 82 89 82 86 98 84 96 89 97 96 91 97 94 93 95 97 97 95 96 97 9...

output:

BBRBRRBRBBBRBRRRRRBBBBBBRBRRR
RRRBRBRRRRRRBRBBBBRBBBBB
BRBBRBRRBRBBRRBRRRRBBRBRBRBBRBRRBRRBBBBBRBRRRBRBRBRRBBRBBRBBBRBRRRBRRRBBBRRBBBR
RBBBBRRRBBRBRBRBRRBRBRRBR
BBRRBBBRRRRBRRRRRRBBBRBBRBBRBBBRRBRBBRRBBBBBBRRRRR
RRBBBBBBBBRRRBRBBRRBRRRRBRBRBRRRBRBB
BRBBBBRBRRRRBRRBBRBRBRRBBBRRBRRBBBRRRB
BBBRRRB
BBRR...

result:

ok ok (1000 test cases)

Test #4:

score: 0
Accepted
time: 18ms
memory: 4372kb

input:

10
9442 9473
6729 7355 6467 7301 7964 7025 7066 7206 8711 8044 7401 6634 6594 9405 7767 7253 7611 6730 6630 8250 6872 6720 8868 8644 9280 7272 6808 8887 7965 7384 6376 9115 8340 7618 8377 9351 8690 8842 9014 6913 7207 7552 8087 9013 9340 6509 8152 6963 8666 8716 7681 6447 8097 7014 6854 8576 6915 92...

output:

BRBRBRBRBBRRRBBBRRRRBBBRRRRRRBBBBBRRBRRRBBRRRBRBBRBBBRBRRBBRBRBBRRBRBRRRRRBBRRBBBBRRRBBRBBBBRRRBRRRBBRBBBBBBBRBRRBRRRRBRBRBRBBBRBBBRBBRRBRRBRRBRBRBRRRRRBBBBRBRBBBRBRRBBRBBBBBRRRBBRRBRRRBRBBRRRRBRBBRBBBBRBRBBRRBBBBBBRRBBBBBRRRBBBRRRRBBRBBBRBBRRRBBRRBRRBBRRBBBBBBRBBBRRBBBRRRBBBRRBRRBBBBBRBRBRRBRBBBBBB...

result:

ok ok (10 test cases)

Test #5:

score: 0
Accepted
time: 16ms
memory: 12548kb

input:

1
100000 100000
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...

output:

R

result:

ok ok (1 test case)

Test #6:

score: 0
Accepted
time: 31ms
memory: 9676kb

input:

1
100000 100000
27 17 44 12 22 19 14 21 15 11 48 13 16 20 34 18 24 26 25 28 43 23 33 29 31 30 46 45 41 36 32 38 90 35 40 37 39 55 47 42 59 52 65 72 49 50 54 53 51 64 56 57 66 58 63 82 62 61 60 69 86 95 85 71 68 67 83 70 74 73 77 75 81 76 78 88 89 79 80 84 94 96 123 106 110 87 92 91 99 102 93 98 101 ...

output:

RBBBRBBRRR

result:

ok ok (1 test case)

Test #7:

score: 0
Accepted
time: 50ms
memory: 9528kb

input:

1
100000 100000
218 381 317 660 186 296 679 224 357 361 193 231 232 288 310 183 209 206 182 300 400 344 250 440 519 563 203 333 346 543 427 447 245 289 202 386 221 249 256 359 257 370 200 393 263 270 340 191 240 644 489 522 380 453 241 207 345 719 261 336 364 260 211 541 178 215 383 220 886 403 441 ...

output:

RRRRRBRRBBRBBRBBBBBBRBRRRBRRRBRRRRBBBRRRRBBRBBRRBBBBBRRBRRBRBBRBRRRBBBBBBBRRRRBBRBRBRBRBBRBRBBBRRBBBRRBBRRBRBBRBBRBBRBBRRBBRRRBBBRBBRBBRRRRRRRBBRRBBRRBRRBRRRRRBRRBBBRBBRRBBBRRB

result:

ok ok (1 test case)

Test #8:

score: 0
Accepted
time: 54ms
memory: 9448kb

input:

1
100000 100000
1421 2788 1423 1160 1112 1488 1236 5948 1163 1757 1410 2312 1361 2923 1593 1342 1999 1293 1081 2501 1942 2294 1893 1059 1610 1844 1256 1287 3866 2443 1668 2351 2721 1191 1618 1058 2556 1182 4821 1303 1528 2149 1564 1294 2339 1490 2179 3047 1645 1178 1536 3950 1275 8455 1068 2870 2234...

output:

RBBRRBBBRRBRRRBBBBRBBBBRRBBBRBBBRBBRBBRBBBRBRRRRBRBBBBRBRBRBRBBRBBRBRRBBRRBBRBRRBBRRBRRRRBRBBRRBRBRRBBBRBRBRRRRBBRRRBRRBBBBBBRBBBRBBRBRBBRRRRBRBBBBBRRRRBRRRRRBBBBRBRBBBRRBBBBBBBBRBRBRRRBBBBBBBRBRRBBRBRBBRBBRRRRBRBBBRRRRRRBBBBRBRBRBBRRRBBBRBBBBRBBBRBRBRBRBRRBBRRRRBBRBRRBRRBRRBRRBRRRRRBBBRBRBBBRRBRBRR...

result:

ok ok (1 test case)

Test #9:

score: 0
Accepted
time: 32ms
memory: 9180kb

input:

1
100000 100000
13732 23027 27029 18787 13613 22155 13102 24134 16692 14811 14984 38995 53389 15109 14007 13571 39616 23329 57926 78696 15054 18000 18665 15849 48065 15896 12897 14354 18446 27792 19390 19744 32923 16980 18489 27104 17926 43496 25322 21020 16210 38766 16458 32680 31819 51489 16147 16...

output:

RRRBBBBBRBBBBBBRBBRBRBRBBRRBBBRRBRRBBRBRBBBRRBRRBBRRRBRBRRBRRRBBRRBBBBBRRRRBBBBBRBBRRBRRRBBRBBRBRRRRRRRBBRRBBBBBBRBBRBBRBRBRRRBRBBRBBBBBRBRRRBRBBRRRBBRBBRRBBBBRBBBBRRRBBBRBBBRBRRRBBBRRBRRRBBBRBRBBBRBBBBRRRBRRBRRBBRRRBBRRBRBRRBBRBBRBRRRRRBBBRRRRRRBRRBBBBBBRRBBRBBBRBBRRRRBRBRBRBBBRRBRRBBBRRRRBRRRRRBBR...

result:

ok ok (1 test case)

Test #10:

score: 0
Accepted
time: 18ms
memory: 7880kb

input:

1
100000 100000
96980 98039 98580 93297 93757 97307 99757 94452 92927 98214 98011 93924 93860 95890 92565 93639 93376 92841 93009 93010 98649 93905 99583 97162 96430 99638 99287 94535 94294 98896 92712 98796 96197 94388 99111 96453 94989 97747 95737 96731 97796 98914 95663 93712 93423 94795 96869 98...

output:

RBBRBBRBBRRBBBBRBBRRBRRRBBBRRRBBRBBRRBRRBBBRBBRRRBRRRBBBRRBBBRBRBBRBBBBRBBRBBRRRBRBBRRRRBRRBRRRBBBRRBRRBRRBBBBBRRRRRRRRBBBRBRRBBRBRRRRBRBBRRRRBBRRRBRRBRBRBRRBBBRBBRBBBBBRRRRBBRRRBBRRRBRRBBRRBBBBBBRRRBRRBBRRRBRRBBRBRRBBBRRRBBRRBRRRRBBBRRBBBBRBBRRBBRRBBBRRRBBBBBBRBBRRRRBRRBRRBBRRBBRBRRRRBRRRRBRRRRRRRR...

result:

ok ok (1 test case)

Test #11:

score: 0
Accepted
time: 16ms
memory: 9112kb

input:

1
100000 30
51 28 32 13 22 18 19 20 12 25 21 14 15 16 23 17 29 33 27 24 39 35 26 34 37 46 42 31 30 36 41 40 38 50 48 71 44 79 45 58 43 68 47 93 54 49 53 60 66 57 52 55 63 56 62 67 76 59 64 61 78 65 69 74 70 89 75 118 77 72 73 81 80 84 111 95 87 82 98 85 83 86 90 96 121 91 88 94 92 99 97 100 101 102 ...

output:

RBBBRRRBBRR

result:

ok ok (1 test case)

Test #12:

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

input:

1
3 3
3 3
3 3

output:

RB

result:

ok ok (1 test case)

Extra Test:

score: 0
Extra Test Passed