QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#330511#7559. Bocchi the RocknamelessguguguAC ✓2130ms12400kbC++178.3kb2024-02-17 16:35:202024-02-17 16:35:22

Judging History

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

  • [2024-02-17 16:35:22]
  • 评测
  • 测评结果:AC
  • 用时:2130ms
  • 内存:12400kb
  • [2024-02-17 16:35:20]
  • 提交

answer

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <utility>
#include <vector>
#include <array>
#define FILEIO(filename) (freopen(filename ".in", "r", stdin), freopen(filename ".out", "w", stdout))
typedef long long ll;
typedef unsigned long long ull;
using std::pair, std::vector, std::array;
constexpr int N = 50005, mod = 998244353;
inline constexpr int qpow(int x, int y)
{
    int res = 1;
    for (; y; y >>= 1, x = 1ll * x * x % mod)
        if (y & 1)
            res = 1ll * res * x % mod;
    return res;
}
inline constexpr int qmod(int x)
{
    return x >= mod ? x - mod : x;
}
constexpr int G = 3;
inline vector<int> pwinit(int mx)
{
    vector<int> res(mx << 1);
    for (int i = 1; i <= mx; i <<= 1)
    {
        int w = qpow(G, (mod - 1) / (i << 1));
        for (int j = 0, cur = 1; j < i; ++j, cur = 1ll * cur * w % mod)
            res[i + j] = cur;
    }
    return res;
}
const vector<int> pwG = pwinit(1 << 18);
class Poly : public vector<int>
{
    inline Poly dft(int n) const
    {
        Poly res(*this);
        res.resize(n);
        for (int l = n >> 1; l;l >>= 1)
            for (int i = 0; i < n;i += (l << 1))
                for (int j = 0; j < l;++j)
                {
                    int v = res[i + j + l];
                    res[i + j + l] = 1ll * pwG[l + j] * (res[i + j] + mod - v) % mod;
                    res[i + j] = qmod(res[i + j] + v);
                }
        return res;
    }
    inline Poly idft(int n) const
    {
        Poly res(*this);
        res.resize(n);
        for (int l = 1; l < n; l <<= 1)
            for (int i = 0; i < n; i += (l << 1))
                for (int j = 0; j < l; ++j)
                {
                    int v = 1ll * pwG[l + j] * res[i + j + l] % mod;
                    res[i + j + l] = qmod(res[i + j] + mod - v);
                    res[i + j] = qmod(res[i + j] + v);
                }
        std::reverse(res.begin() + 1, res.end());
        res = res * qpow(n, mod - 2);
        return res;
    }
    inline static Poly cycconv(const Poly &a, const Poly &b, int n)
    {
        if (n <= 128 || std::min(a.size(), b.size()) <= 64)
        {
            Poly res(n);
            for (int i = 0; i < (int)a.size(); ++i)
                for (int j = 0; j < (int)b.size(); ++j)
                    res[(i + j) & (n - 1)] = (res[(i + j) & (n - 1)] + 1ll * a[i] * b[j]) % mod;
            return res;
        }
        Poly &&ta = a.dft(n), &&tb = b.dft(n);
        Poly res(n);
        for (int i = 0; i < n; ++i)
            res[i] = 1ll * ta[i] * tb[i] % mod;
        res = res.idft(n);
        return res;
    }

    public:
    explicit Poly(int n = 0) : vector(n)
    {
        return;
    }
    explicit Poly(std::initializer_list<int> v) : vector(v)
    {
        return;
    }
    explicit Poly(std::vector<int> v) : vector(v)
    {
        return;
    }
    inline Poly rev(void) const
    {
        Poly res(*this);
        std::reverse(res.begin(), res.end());
        return res;
    }
    inline Poly substr(int l, int r) const
    {
        Poly res;
        res.insert(res.end(), this->begin() + l, this->begin() + r);
        return res;
    }
    inline friend Poly operator+(const Poly &a, const Poly &b)
    {
        int n = std::max(a.size(), b.size());
        Poly res(a);
        res.resize(n);
        for (int i = 0; i < (int)b.size(); ++i)
            res[i] = qmod(res[i] + b[i]);
        return res;
    }
    inline friend Poly operator-(const Poly &a, const Poly &b)
    {
        int n = std::max(a.size(), b.size());
        Poly res(a);
        res.resize(n);
        for (int i = 0; i < (int)b.size(); ++i)
            res[i] = qmod(res[i] + mod - b[i]);
        return res;
    }
    inline friend Poly operator*(const Poly &a, int b)
    {
        Poly res(a);
        for (int &x : res)
            x = 1ll * x * b % mod;
        return res;
    }
    inline friend Poly operator*(int a, const Poly &b)
    {
        Poly res(b);
        for (int &x : res)
            x = 1ll * x * a % mod;
        return res;
    }
    inline int operator()(int a)
    {
        int res = 0;
        for (int i = 0, cur = 1; i < (int)size();++i, cur = 1ll * cur * a % mod)
            res = (res + 1ll * cur * at(i)) % mod;
        return res;
    }
    inline friend Poly operator*(const Poly &a, const Poly &b)
    {
        if(a.empty() || b.empty())
            return Poly();
        int n = 1;
        while (n < (int)(a.size() + b.size() - 1))
            n <<= 1;
        Poly res(cycconv(a, b, n));
        res.resize(a.size() + b.size() - 1);
        return res;
    }
    inline void add(int p, int v)
    {
        if(v == 0)
            return;
        if ((int)this->size() <= p)
            resize(p + 1);
        this->at(p) = (this->at(p) + v) % mod;
        return;
    }
};
using Info = array<array<Poly, 2>, 2>;
Info operator+(Info a, const Info &b)
{
    for (int x = 0; x < 2;++x)
        for (int y = 0; y < 2;++y)
            a[x][y] = a[x][y] + b[x][y];
    return a;
}
Info operator*(Info a, int b)
{
    for (int x = 0; x < 2; ++x)
        for (int y = 0; y < 2; ++y)
            a[x][y] = a[x][y] * b;
    return a;
}
Info operator*(const Info &a, const Info &b)
{
    Info res;
    for (int i = 0; i < 2; ++i)
        for (int j = 0; j < 2;++j)
            for (int k = 0; k < 2;++k)
                for (int l = 0; l < 2;++l)
                {
                    if(j != k)
                        res[i][l] = res[i][l] + a[i][j] * b[k][l];
                    else
                    {
                        Poly tmp = a[i][j] * b[k][l].rev();
                        for (int x = 0; x < (int)tmp.size();++x)
                        {
                            int id = x - (int)b[k][l].size() + 1;
                            if(id < 0)
                                res[i ^ 1][l].add(-id, tmp[x]);
                            else
                                res[i][l ^ 1].add(id, tmp[x]);
                        }
                    }
                }
    return res;
}
using Group = array<array<Info, 2>, 2>;
int n, lim[2][N];
char s[N << 1];
Group solve(int l, int r)
{
    Group res;
    if (r - l == 1)
    {
        if(lim[1][l] & 1)
            res[0][0][0][1].add(0, 1);
        if (lim[1][l] & 2)
            res[1][1][0][1].add(0, 1);
        return res;
    }
    int mid = (l + r) >> 1;
    Group vl = solve(l, mid), vr = solve(mid, r);
    for (int x = 0; x < 2;++x)
        for (int y = 0; y < 2;++y)
            for (int z = 0; z < 2;++z)
                for (int w = 0; w < 2;++w)
                {
                    if(y == z)
                        res[x][w] = res[x][w] + vl[x][y] * vr[z][w] * ((lim[0][mid] & 1) + (lim[0][mid] >> 1));
                    else
                    {
                        Info tmp;
                        if(lim[0][mid] & 1)
                            tmp[0][0].add(1, 1);
                        if(lim[0][mid] & 2)
                            tmp[1][1].add(1, 1);
                        res[x][w] = res[x][w] + vl[x][y] * tmp * vr[z][w];
                    }
                }
    return res;
}
int main(void)
{
    scanf("%d", &n);
    scanf("%s", s);
    std::rotate(s, s + 1, s + 2 * n);
    for (int i = 0; i < n; ++i)
    {
        if(s[2 * i] == '?')
            lim[0][i] = 3;
        else if(s[2 * i] == 'R')
            lim[0][i] = 1;
        else
            lim[0][i] = 2;
        if(s[2 * i + 1] == '?')
            lim[1][i] = 3;
        else if(s[2 * i + 1] == 'Y')
            lim[1][i] = 1;
        else
            lim[1][i] = 2;
    }
    Group res = solve(0, n);
    Info tmp;
    if (lim[0][0] & 1)
        tmp[0][0].add(1, 1);
    if (lim[0][0] & 2)
        tmp[1][1].add(1, 1);
    int ans = 0;
    for (int i = 0; i < 2;++i)
        for (int j = 0; j < 2;++j)
        {
            if(i == j)
                res[i][j] = res[i][j] * ((lim[0][0] & 1) + (lim[0][0] >> 1));
            else
                res[i][j] = res[i][j] * tmp;
            for (int x = 0; x < 2;++x)
                if(res[i][j][x][x ^ 1].size())
                    ans = (ans + res[i][j][x][x ^ 1][0]) % mod;
        }
    printf("%d\n", ans);
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 4ms
memory: 5140kb

input:

2
????

output:

12

result:

ok 1 number(s): "12"

Test #2:

score: 0
Accepted
time: 3ms
memory: 5124kb

input:

3
??YR?B

output:

4

result:

ok 1 number(s): "4"

Test #3:

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

input:

5
YBYRPBYRYB

output:

0

result:

ok 1 number(s): "0"

Test #4:

score: 0
Accepted
time: 3ms
memory: 5172kb

input:

10
PRPBPRPRPRPBYB?R?BY?

output:

3

result:

ok 1 number(s): "3"

Test #5:

score: 0
Accepted
time: 3ms
memory: 5200kb

input:

10
?R?R?BYB?R?R?B?B?BYR

output:

96

result:

ok 1 number(s): "96"

Test #6:

score: 0
Accepted
time: 3ms
memory: 5172kb

input:

10
YRPRYRY???P?YB?BYRY?

output:

32

result:

ok 1 number(s): "32"

Test #7:

score: 0
Accepted
time: 3ms
memory: 5208kb

input:

10
PBYBPRPBYRPBYRYBPRPB

output:

0

result:

ok 1 number(s): "0"

Test #8:

score: 0
Accepted
time: 3ms
memory: 5040kb

input:

10
PBPRPRYBYRYRYB?B?RYB

output:

0

result:

ok 1 number(s): "0"

Test #9:

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

input:

10
PRP?PBPRYR??Y?YRPB?R

output:

12

result:

ok 1 number(s): "12"

Test #10:

score: 0
Accepted
time: 3ms
memory: 5152kb

input:

10
?RYB??P??B?B?B???RPR

output:

416

result:

ok 1 number(s): "416"

Test #11:

score: 0
Accepted
time: 210ms
memory: 5888kb

input:

50000
YBPBYRPRPRPRPBPRPBPBPBYRPRPBPBYRPBPRYBYBPBPBPRPBPBYRYBYRPBYRYRPBYRYRYRPBYBYRPBPBYBYBPBYRPBPBYBYBYRPBPRYBPBYBPRPRYBPRPBYBPRPBYRPBYBPRYBPBPBYRYBYBYBPRYBYRPRPRPRPRYRYBPBPBPBPRPRYBYRYBPRPRPRPBYBPBPRYRPRPBYRPBYRYRPBYBYBPBYRYRPBPRYBPRYBPBPBYRPBPBYBYBPRPBYBYBYRYRPBPRPRPRPRPRYBPBPBPRYBYRPRPRYBYRPRPBYR...

output:

0

result:

ok 1 number(s): "0"

Test #12:

score: 0
Accepted
time: 210ms
memory: 5788kb

input:

50000
YRPBPBYRYRYRYBYBYRPBPBPBPBPBYRYBPBPRYBPBYRYRPRYBYBYBYRPRPBPBPRYRPBYBYBPBYRYRPRPBPBPBPRYBYBYRYRPRPRYBPRPBYRPBPRYRPRYBPRYBYBYRYRYBYRYRYBYRPBPBPBYBPBPRPBPRYRPRYBYBPBPRPBPBPRPRPBYRYRPBPBPBYRPBYBYBYRPBPRPBPRYBPRPRYBPRPBPBYRYRYRYBYRPRPRYBYBYBPBPRPBPRYRYRPRPRPBPBPRPRPBYBYRPRPRPBYBYRPBYBPRPRPRPRPRPBPB...

output:

0

result:

ok 1 number(s): "0"

Test #13:

score: 0
Accepted
time: 209ms
memory: 5840kb

input:

50000
PRPRYBPBYBYBPBYRPBYRYBPBPBPRPRPBYBYRPRPRPRPRPRYRYBYRPBPBPRYRPRPBPRPBPRPRPRPBYRYRYRPBYBYRYRPRPRPRPRYBYBYBYBPBPRPBPBPRYRPRYRPRPRYRPRPBPBYRYBPRPRYRPBPBYBYBPBYRPBPRYRPRYRYBPBPBPRPBPRPRPRYBPBPBYBYBPRYRPRYRPBYRYBYRYRPBYBPBPRPRYRPRYBYRPRPRYBYBYBPBYRYRYRYRYRYRPBYBYRYRYBYRPRYRPBPBYBYRYBPBYBPRYBPBYRYBPR...

output:

0

result:

ok 1 number(s): "0"

Test #14:

score: 0
Accepted
time: 210ms
memory: 5780kb

input:

50000
YRPRPBPRYRYRPRYBPBYRPRPBYRYRYRPBPBYRPRYBYBYBPRYRPBPRPBPBYRPRPRPBPBYBYBPRPRPRYRYRYBYRPBYBPBPRYBPRYBYBYBPBYBYBPBPBPRYRPRPBYRYBYRPRYBYRPRYRPRPRYRPBYRYRYBYRYRPRYRYRPBPRPBYRYRPBYRPBPBPBPRPBYBYBPRYBPBPBYRYRYBYRPRPBPRYBPRPBYRPBYBYBPBPRPBYRYRPRPBPRPBPBYRPRPBYRPRPRYRYRPBYBYBPBPBYBPBYBYRYBYRPBPBPBPRYRPB...

output:

0

result:

ok 1 number(s): "0"

Test #15:

score: 0
Accepted
time: 207ms
memory: 5828kb

input:

50000
YBPBYRPRYRPRPBPBYBYRPBYRPBPRPRPBPBPBYRYBYRPBYRYRPBYRPRPRYBPRYRYBYBPRPRYBYBPRPRPRYRPRYBPRPBYRPBYRPBYRPRPBPBPRPBPBYRYBPRPBPBPBPBYRYRPRPRYBYRPRYBYBYBYBYRYRPBPRYRYRPRYBPRPBPRPRPRPRPBPRPBYBPBPBPBYRPBYBPBPRPBYRPRPRYRYBYRPRPBPRYBYRPBPRPBPRYRPRYBYRYBYBPRPRPRPBYRPBPBYRYRPBPRYBPRYBPRYBPRYBYRPBYBPBPBYRPR...

output:

0

result:

ok 1 number(s): "0"

Test #16:

score: 0
Accepted
time: 34ms
memory: 6016kb

input:

5000
PR?BPB?BY?PRY??RPB?R??YBY?P?YRPBYBPRP?YBYBYRPRPB?BPBPR?RYR??Y??RYR?BPRYR?RPRP?Y?PRY?Y?YB??PBYRYR?RPB?BPB?BY?P?Y?YBY??RPB?BPRPBY???PRP?YB?R?RP?PR?BPB???R?B?RP?PBYB?BPRYBP?P??B?RPRP???P???PRYB?RYRP?Y??RPR?BP?PR?BPBPRYR?B??PB??YBPB?B?BY?YB?RY?PR?RYB???BYBP?Y??RYRYB?RYBYBPBYRYBP?YBYR?RPBYBY?YRP??R?...

output:

101508706

result:

ok 1 number(s): "101508706"

Test #17:

score: 0
Accepted
time: 36ms
memory: 5928kb

input:

5000
Y?P?PBYBYBPBYB?RYBPRPB?B??YRY??RP?PB??P??BYR?B?BP??R?R?R?BYBP??BY?Y?PBY?Y?YR?RY?PRPR?R?RPR?RPR?BYR?B?B?RPRPR?RP?Y?YRP?Y??RYB????YRY?YR?BP?YB?B??Y??B?RPBYR?RP????B?RPR??????P?PRPR?RP?PR?????BP?P?YB?BYRP?PBP?YBYB?RPR?R?B?BYRYR?RPBPBY??BYBPRYRPBPB?R?RPR?BYBP?YRY?PR?BPR?RY????BYBYB?RYRP???Y???PBY?Y...

output:

748282195

result:

ok 1 number(s): "748282195"

Test #18:

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

input:

5000
P?PRPRPBP??RYB??YBPBYRYB?BP?YB?B?BY??R?BYRP??BPRY?YBYB?RY????B??????PB?RP?P??R?BPB?BY?PR?RPBPBPR?BY?YB?BYBYRYBYRYBY?Y??RP?YR?R?R?BY?PBY??RYBPBYBYBY?PBY?P?YB?RYR???RY?YBY?YRYRY?PBY?P?PBYRPRY?PBP???PBYRPRY?Y?P?P?Y?PR???B?B?RP???PBY?P?PR???BP?PR????P?YB??YR??YRYBYR?B?BP??BPB??P?Y?PRYRY?YB??YR?RY?Y...

output:

24097861

result:

ok 1 number(s): "24097861"

Test #19:

score: 0
Accepted
time: 38ms
memory: 5776kb

input:

5000
??PBPRYBPR??PRP?PRYBY???P?YRPBYBY?YR?RYR??Y?P?YRPR?BPBY?PRPRYB?RYBY?P?????YBPBYBY?Y??BY?PB???BP?P?Y???YR??YBP???YRYB?BPBPRP???PRY??B???BPB???R?RP?PB???BYRP?YB?BP??RP?PBYRPRPR??P??RY????B?????RP?YBYBPRYBYB?RYRYBP??RPB??YRPBY?PBPBP?YRYBPR?BPRYBPB???BYR?RY?PB?RYRY??BYRP?Y?YRP?PRPR????Y?PRPRYBP?YBP...

output:

447561693

result:

ok 1 number(s): "447561693"

Test #20:

score: 0
Accepted
time: 35ms
memory: 5912kb

input:

5000
P?P?P??????BPR?RY?PR??Y?Y??BPR??PB?B??PRP?YB???RPRPRPBY??R??PRYBYR?RPR?BP??R?B?RYRPRP??B?BYRY??R?RP???P?PRP??RY??RY?YBY???????P?Y?PBPRYBPRYRY?P?PB?BPR??P?Y?Y?Y?PR?RPB??Y??BYRP?PRPRY??R?RYBPR??YBP??B?RPRYBPR?BP??BYBYBPRYRPBPRPRY?Y?YBYRPBP?PB??Y?P??????R?BPBYR???BPR?B?R???BYR?BP?P?Y?YRY?PR??YBYB?...

output:

987042679

result:

ok 1 number(s): "987042679"

Test #21:

score: 0
Accepted
time: 24ms
memory: 5152kb

input:

5000
PRPBPRPRYRPRPBYBPBPBYRPBPBPBYRYRYBPBYRPRYBPBPRYBPBYRPRYBYRYRPBPBPBPBYRPBYRYBYRPRYBPBPBPRYBPRYBYBPRPBPBYRYBPRPBYRYRPRYBPRPRPBYRPBYRYRPRPRYRYRYBYBPBPBPBPRPRPBPRPRYRPBYRYRYRPBPRPRYRPRPBYBYBPBPRPRYRPBPRYBPRYBPRPRYRPRYRPBPRYBPRPRYBYRPBYRPRYBPRPRYBYRPRYRYBPRYBPRPBPRPRPRYBYRYRYRYRPBPRPBPRPBPRPBPRYRYBY...

output:

0

result:

ok 1 number(s): "0"

Test #22:

score: 0
Accepted
time: 24ms
memory: 5168kb

input:

5000
PRYRYBPBPRYRYRYRPBPBYBYRPBPBYRPRPRYBYRPRYRPBPRYBPBYRPRYRYRYBPBPBYBPBYBPBYRYRYRYRYBYRPRPBYRYBPRYBYBPRPRPBYRYRYRPBYBPBPRPRYRPRPBPRYBYBPBPBYBPBPBPRPBYRYRYRYRPRYBYBPBYBYBPBYBYRPRYRPRPRYBYRYBYRYRYBYBYRPBPRYRYRPRPRPRPRYRPRYRYRPBYBYRPBYBPBPRYBPBYBPBPRYRYRPBPRPRPBPRYRPRYBPBYRPRYBPBYRYBPRPRYRYBYBPRPBYBP...

output:

0

result:

ok 1 number(s): "0"

Test #23:

score: 0
Accepted
time: 24ms
memory: 5024kb

input:

5000
PBYRYRYBYBPBYBYBPBYBYRPRYBYRPRPBYRYBPRYBPRPRYRYRPBYRYRPRYRYBPBYBPBPRPBPRPBPBP?YRPBYBYBPRPRPBPRYRPRYBPRYRYBYRPRYBYBPBYRPBPBYBYRYBPRPBYRYBPBYBYRYRYRPRPRYBYBPRYRPRYBYBYBPRYBPBYRYBPBPRPRPBYBYRYBYRPRYBYBYBYBYBPBYRPRPRPRPRYBYRPRYRYRYBYRPBYRPBPRPRYBPBYBYRPRYBPRYBPRPRPRPBYRPRPBYRYBY?PRYRYRYBPRYRYBYRYBY...

output:

172032

result:

ok 1 number(s): "172032"

Test #24:

score: 0
Accepted
time: 46ms
memory: 5840kb

input:

5000
????YRPB??PB??Y?Y??R??P?PRY?P??B??PBPBP???PRP??RY??RP?YRYB?R?BY?P??B?B??Y??R?RYRYRP???P?YBPR?R????YBP???P????R?R?BPR??Y?Y?YBP?Y??RY???PR??????P?P?Y??B?R?????B??Y?Y??BY??B?B???RYR???R?RY??RP?PR?RY?PB??Y?P?P???P??B?R??YR?BYRY??????R??Y??RYRPBYR??Y?P?P??B?RP?Y??B?BPBP?P???Y??B?RY?YBYB?RYRYRYBYB???...

output:

589400951

result:

ok 1 number(s): "589400951"

Test #25:

score: 0
Accepted
time: 169ms
memory: 6264kb

input:

5000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

312356960

result:

ok 1 number(s): "312356960"

Test #26:

score: 0
Accepted
time: 396ms
memory: 7404kb

input:

50000
YR?BPR?BP??B??YBY?PRY?PRYB??PB?BPBY??R???RPR??Y?Y???PR???BPBPRPRY?Y?P?Y?P?YR??YR?RP?YRP??B?B???R??YR?BPR?B?R?R??Y?YBYRPR?BPBPRPRPB??YBPR??PR??Y??RYBY??RPRPB??YBPR??PBY?PBPBPRPRPRYRYB??YR?BYRP?P??RYR?R?R?RPBP?Y?YR??YBYR??YRYR???BPRPR???BP??B?BPBYBYBYR?B?RPRPBP?P?YBPB?R?BPBPR?BP?PRYRPB?BY?Y??B?B...

output:

61578469

result:

ok 1 number(s): "61578469"

Test #27:

score: 0
Accepted
time: 475ms
memory: 8100kb

input:

50000
Y??RPRP?PBYR?BPRPBYB??YBP?PBPB?????B?BYRYBPBYBPRPRYBP?P?YB?B??PBY?PB?R?RPR?RYBY?Y?PBY????B??YBYRPRY??BYR??PRPBP?P?P?Y?YBPRPBYBPRP???Y?P??RPBYBPBY??BY?Y?YRPB??Y?PBYB??P?Y?PRYBY?YBY??R?B??PR???BYRYB?RPBPBPBPR?RP??BYRYB?BP?PRP?P?YBPRP?PBYR???R?RPBP?P?YB?RPR?RYRP??B?RYRYRYBP??B???BYRYRPB??YRPRYBPB...

output:

21239954

result:

ok 1 number(s): "21239954"

Test #28:

score: 0
Accepted
time: 419ms
memory: 7980kb

input:

50000
YR??PB?BP???YRP??BYRPRP?P?PRPRPR?RPRPBYBPBY??B?B?RPRPBYRP??R?B??PR??P?PR?RYBPRPRY????R?R?RY??B?RYB?R?B?BYBPB??YRYRYBY?P?PR?B?RP??RP?YRPRYBPBYB?BYBP????RYRYR?BPRP?YRY?PB???BP??????BPR?RP?YBPB?RY?PBPBP??BYRP?YBYRP?YBYB?RPRYBYBP?YBY?YB?R??PBYBY?PB?R????P??BPRPRPRY???P???PBPRYRYB?RP?YBYRYRY????RP?...

output:

268137953

result:

ok 1 number(s): "268137953"

Test #29:

score: 0
Accepted
time: 388ms
memory: 7232kb

input:

50000
P???PR?RYBPB?RPBYB??YR??PB??YBPBP?Y?P??R?RYBPRPBYB??YB?R????YR?RPRPB?RYB?RPRP???PBYBY?YB?BYR??PR?B???B?R?RPR?RPR??PR?BYBPR????P???P?YRPR??P?PRYRYB?BYBY???P?PB?R??P??RYBPB?R?RYB???B????PRPRYR???BYRYR?B??PBP???PRP?P?YR??YRP??B?BY?Y?PRPRPRYRYRYRPRY?Y??RPBY?YR?BPRPB?R?BYR?BY??BY?P?Y?YBYRYBYRY?P??R...

output:

903429393

result:

ok 1 number(s): "903429393"

Test #30:

score: 0
Accepted
time: 415ms
memory: 7620kb

input:

50000
P??RPBYB?RP?Y??BPBPBPBYRPRPBYRP?YR??P?PBY?Y?????PRYBPBP?Y??BY??BPR?BYB???R?B??YBYRP??BP?YBPRP?YBP?P?Y?PR??YRPBYBPR?BPBY?PRY??RP???PRYBP?YRP?P??R??P?YBPR??P?PRYB?BPRYRYBP??BYB?RP??RPB??PR?R??YBPR?B??YBY?Y???P??BYRP????RYB?RYR?BP?YBP?P???P?PB??PR?RP?PR?R??P?YB?B??P?YRY?Y??RY?P?YBYBYRYRY?YRPBYBYB...

output:

360140728

result:

ok 1 number(s): "360140728"

Test #31:

score: 0
Accepted
time: 206ms
memory: 6068kb

input:

50000
PBYRYRYBYRYBYRPBYRPBPBYBYRYBYBPRPBYRYRYBYRPBPRYBYRYRYRYBYRYRYRPRYBYRPRPRPRYRPBYRPRPBYRPBYRYRPBYRYBPRYRPRYBYBYRYBPRPBYBPRPRPRYRPRYRPRYRPBYBPRPRYRYRPRPRPBYRYRYRPRPBPRPRYRYRYBYRYRYRPBYBYRPBPBYRPRPBPRYBPRPBYBPBPBPBYRYRPRPBYRPBYRYBPRPBYRYBPBPRPRPBYBPRYRPBYBYBYRPRYBYBYBPBYBPBPRYRYRYRPRYBYBYBPBPBYBPR...

output:

0

result:

ok 1 number(s): "0"

Test #32:

score: 0
Accepted
time: 210ms
memory: 5872kb

input:

50000
PRYRPBPRYRYBYRYBYRYRYRPRPBPRPRYBYBPBYRPRYRYRYRYRPBYBPRPRPRPRPRPRYBPRPBYBPBYBYBYRPRPBYBYBYBYBPRPBYBPBPRYRYBYBPBYRYBYRPBYRYRYRYBYBYRYBYRPRPBPBPBPBPBPRPRYBYRYRPBPRPRYBYRPRYRYRYRYRPRPRYRPBPRYRYRPBYBPRPBYRYRYBYRYBPRYBYRYRPRYBYBPRPBYRPBYBYRYRYRYBPBPRPBYBPBYRYBYRPBPBYBPRYBYRYBPBYRYRPBYBPBYBPRPBYBYRYB...

output:

0

result:

ok 1 number(s): "0"

Test #33:

score: 0
Accepted
time: 206ms
memory: 5872kb

input:

50000
PBPRPBYRPRYBYBYRPBPBYRPBPRPBPBPBYRPBYBYRPRYBPRPRYRYBPBPBYRPRYRYRPBYRYRPBPBYRPBPBYRPBYRYBYRYBYBYRYBPRPBYRYRYRPBYRPBYBPRYRYBPRYBYBYRPBPRYRYRYBYRPBPBPBPBPRYBYRPBYBYRYRYBYRYRYBYRPRYRPBYRPBPRYBYRPBPBYRYRPRYRYRYBPBYRPRPRPBPRPRYRPBPBYBPBPBYBYBYBPBYBPRPBYBYRPRPBYBPRPBPRPBYRPBPRYRPRYRYRYBPRPRPRYRPBYBPR...

output:

0

result:

ok 1 number(s): "0"

Test #34:

score: 0
Accepted
time: 558ms
memory: 8556kb

input:

50000
?BY???P????RPB??P???YB?R?BY?YR????PR??P???????P?YRP?PRY?PB??Y?YR???B??Y?YR?BPRYR?B?B?BPRY?Y???PRY?PBYBPRP?Y?PBY?YRP?PR?R??PRYRY?Y?Y?Y?P?PBPB?RP?PRY?P???PRY???P???P???PB?B?B?B?B?BYBP?PR????P??BYRY??????R?B??P?????PBY??R?B??Y?YB??PBPB?B???R?BP??B?BPB?R????YR????YBP?P?YR????Y?PRPB??Y????R?R?RY??B...

output:

908700788

result:

ok 1 number(s): "908700788"

Test #35:

score: 0
Accepted
time: 2130ms
memory: 12400kb

input:

50000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

422064317

result:

ok 1 number(s): "422064317"