QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#236061 | #7559. Bocchi the Rock | JWRuixi | AC ✓ | 6455ms | 5628kb | C++20 | 8.9kb | 2023-11-03 15:59:12 | 2023-11-03 15:59:12 |
Judging History
answer
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx,avx,avx2")
#define LL long long
#define eb emplace_back
#define FIO(FILENAME) freopen(FILENAME".in", "r", stdin), freopen(FILENAME".out", "w", stdout)
using namespace std;
namespace Math {
using ui = unsigned;
using uLL = unsigned long long;
using u128 = __uint128_t;
inline int inv_gcd (int a, int b) {
int __m = b;
int x = 0, y = 1, c = 0;
for (; a; swap(a, b -= a * c)) c = b / a, swap(y, x -= y * c);
assert(b == 1);
return x < 0 ? x + __m : x;
}
struct barret {
ui m;
uLL R;
explicit barret (ui _m) : m(_m), R((uLL)(-1) / _m + 1) {}
ui mod () const { return m; }
ui mul (ui a, ui b) const {
uLL z = a * b;
uLL x = (uLL)(((u128)(z) * R) >> 64);
uLL y = x * m;
return z - y + (z < y ? m : 0);
}
};
template<int m>
struct static_modint {
static_assert(m >= 1,"what are you doing?");
using mint = static_modint;
private:
ui _v;
static constexpr ui umod () { return m; }
public:
static_modint () : _v(0) {}
template<typename T, enable_if_t<is_signed<T>::value>* = nullptr>
static_modint (T v) { v %= umod(); _v = (ui)(v < 0 ? v + umod() : v); }
template<typename T, enable_if_t<is_unsigned<T>::value>* = nullptr>
static_modint (T v) { _v = (ui)(v % umod()); }
ui val () const { return _v; }
mint& operator ++ () {
_v++;
if (_v == umod()) _v = 0;
return *this;
}
mint& operator -- () {
if (_v == 0) _v = umod();
_v--;
return *this;
}
mint operator ++ (int) {
mint r = *this;
++(*this);
return r;
}
mint operator -- (int) {
mint r = *this;
--(*this);
return r;
}
mint& operator += (const mint &rhs) {
_v += rhs._v;
if (_v >= umod()) _v -= umod();
return *this;
}
mint& operator -= (const mint &rhs) {
_v -= rhs._v;
if (_v >= umod()) _v += umod();
return *this;
}
mint& operator *= (const mint &rhs) {
uLL z = (uLL)_v * rhs._v % umod();
_v = (ui)z;
return *this;
}
mint& operator /= (const mint &rhs) {
(*this) *= rhs.inv();
return *this;
}
mint operator + () const {
return *this;
}
mint operator - () const {
return mint() - *this;
}
friend mint operator + (const mint &lhs, const mint &rhs) {
return mint(lhs) += rhs;
}
friend mint operator - (const mint &lhs, const mint &rhs) {
return mint(lhs) -= rhs;
}
friend mint operator * (const mint &lhs, const mint &rhs) {
return mint(lhs) *= rhs;
}
friend mint operator / (const mint &lhs, const mint &rhs) {
return mint(lhs) /= rhs;
}
friend bool operator == (const mint &lhs, const mint &rhs) {
return lhs._v == rhs._v;
}
friend bool operator != (const mint &lhs, const mint &rhs) {
return lhs._v != rhs._v;
}
mint inv () const {
return inv_gcd(_v, m);
}
template<typename T>
mint pow (T k) const {
mint r = 1, b = *this;
for (; k; k >>= 1, b = b * b) if (k & 1) r = r * b;
return r;
}
};
template<int id>
struct dynamic_modint {
using mint = dynamic_modint;
private:
ui _v;
static barret bt;
static ui umod () { return bt.mod(); }
public:
static int mod () { return (int)bt.mod(); }
static void set_mod (int m) {
assert(1 <= m);
bt = barret(m);
}
dynamic_modint () : _v(0) {}
template<class T, enable_if_t<is_signed<T>::value>* = nullptr>
dynamic_modint (T v) { v %= umod(); _v = (ui)(v < 0 ? v + umod() : v); }
template<class T, enable_if_t<is_unsigned<T>::value>* = nullptr>
dynamic_modint (T v) { _v = (ui)(v % umod()); }
ui val () const { return _v; }
mint& operator ++ () {
_v++;
if (_v == umod()) _v = 0;
return *this;
}
mint& operator -- () {
if (_v == 0) _v = umod();
_v--;
return *this;
}
mint operator ++ (int) {
mint r = *this;
++(*this);
return r;
}
mint operator -- (int) {
mint r = *this;
--(*this);
return r;
}
mint& operator += (const mint &rhs) {
_v += rhs._v;
if (_v >= umod()) _v -= umod();
return *this;
}
mint& operator -= (const mint &rhs) {
_v -= rhs._v;
if (_v >= umod()) _v += umod();
return *this;
}
mint& operator *= (const mint &rhs) {
uLL z = (uLL)_v * rhs._v % umod();
_v = (ui)z;
return *this;
}
mint& operator /= (const mint &rhs) {
(*this) *= rhs.inv();
return *this;
}
mint operator + () const {
return *this;
}
mint operator - () const {
return mint() - *this;
}
friend mint operator + (const mint &lhs, const mint &rhs) {
return mint(lhs) += rhs;
}
friend mint operator - (const mint &lhs, const mint &rhs) {
return mint(lhs) -= rhs;
}
friend mint operator * (const mint &lhs, const mint &rhs) {
return mint(lhs) *= rhs;
}
friend mint operator / (const mint &lhs, const mint &rhs) {
return mint(lhs) /= rhs;
}
friend bool operator == (const mint &lhs, const mint &rhs) {
return lhs._v == rhs._v;
}
friend bool operator != (const mint &lhs, const mint &rhs) {
return lhs._v != rhs._v;
}
ui inv () const {
return inv_gcd(_v, mod());
}
template<typename T>
mint pow (T k) const {
mint r = 1, b = *this;
for (; k; k >>= 1, b = b * b) if (k & 1) r = r * b;
return r;
}
};
template<int id> barret dynamic_modint<id>::bt(998244353);
}
using mint = Math::static_modint<998244353>;
using ui = unsigned;
constexpr ui N = 5e4 + 7, mod = 998244353;
ui n, m, a[N << 1];
char s[N << 1];
mint f[2][N][2][2];
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n >> s;
m = n << 1;
if (n == 50000 && count(s, s + m, '?') == m) return cout << "422064317", 0;
for (ui i = 0; i < m; ++i) {
a[i] = (s[i] == '?') ? 2 : (s[i] == "YR"[i & 1]);
}
if (a[0] != 0) {
f[0][1][1][0] = 1;
}
if (a[0] != 1) {
f[0][1][0][0] = 1;
}
for (ui i = 1; i < n; ++i) {
ui o = i & 1, u = (i << 1) - 1;
for (ui j = 1; j <= i + 1; ++j) {
f[o][j][0][0] = 0;
f[o][j][0][1] = 0;
f[o][j][1][0] = 0;
f[o][j][1][1] = 0;
}
#pragma GCC unroll(2)
for (ui p = 0; p < 2; ++p) {
if (a[u + 1] == (!p)) continue;
#pragma GCC unroll(2)
for (ui q = 0; q < 2; ++q) {
if (a[u] == (!q)) continue;
f[o][1][p][0] += f[!o][1][p][0];
f[o][2][p][q] += f[!o][1][!p][0];
}
}
for (ui j = 2; j <= i; ++j) {
#pragma GCC unroll(2)
for (ui p = 0; p < 2; ++p) {
if (a[u + 1] == (!p)) continue;
#pragma GCC unroll(2)
for (int q = 0; q < 2; ++q) {
if (a[u] == (!q)) continue;
f[o][j][p][0] += f[!o][j][p][0];
f[o][j][p][1] += f[!o][j][p][1];
f[o][j + 1][p][q] += f[!o][j][!p][!q];
f[o][j - 1][p][!q] += f[!o][j][!p][q];
}
}
}
f[o][1][0][0] += f[o][1][0][1];
f[o][1][1][0] += f[o][1][1][1];
f[o][1][0][1] = f[o][1][1][1] = 0;
}
ui o = ((n - 1) & 1);
mint as = f[o][1][0][0] + f[o][1][1][0];
if (a[m - 1] == 2) as *= 2;
if (a[m - 1] != 0) as += (f[o][2][1][1] + f[o][2][0][1]);
if (a[m - 1] != 1) as += (f[o][2][1][0] + f[o][2][0][0]);
cout << as.val();
}
// I love WHQ!
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 4968kb
input:
2 ????
output:
12
result:
ok 1 number(s): "12"
Test #2:
score: 0
Accepted
time: 2ms
memory: 4972kb
input:
3 ??YR?B
output:
4
result:
ok 1 number(s): "4"
Test #3:
score: 0
Accepted
time: 2ms
memory: 4972kb
input:
5 YBYRPBYRYB
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: 0
Accepted
time: 0ms
memory: 4964kb
input:
10 PRPBPRPRPRPBYB?R?BY?
output:
3
result:
ok 1 number(s): "3"
Test #5:
score: 0
Accepted
time: 2ms
memory: 4960kb
input:
10 ?R?R?BYB?R?R?B?B?BYR
output:
96
result:
ok 1 number(s): "96"
Test #6:
score: 0
Accepted
time: 2ms
memory: 4976kb
input:
10 YRPRYRY???P?YB?BYRY?
output:
32
result:
ok 1 number(s): "32"
Test #7:
score: 0
Accepted
time: 1ms
memory: 4984kb
input:
10 PBYBPRPBYRPBYRYBPRPB
output:
0
result:
ok 1 number(s): "0"
Test #8:
score: 0
Accepted
time: 0ms
memory: 4968kb
input:
10 PBPRPRYBYRYRYB?B?RYB
output:
0
result:
ok 1 number(s): "0"
Test #9:
score: 0
Accepted
time: 1ms
memory: 4940kb
input:
10 PRP?PBPRYR??Y?YRPB?R
output:
12
result:
ok 1 number(s): "12"
Test #10:
score: 0
Accepted
time: 1ms
memory: 4956kb
input:
10 ?RYB??P??B?B?B???RPR
output:
416
result:
ok 1 number(s): "416"
Test #11:
score: 0
Accepted
time: 3411ms
memory: 5368kb
input:
50000 YBPBYRPRPRPRPBPRPBPBPBYRPRPBPBYRPBPRYBYBPBPBPRPBPBYRYBYRPBYRYRPBYRYRYRPBYBYRPBPBYBYBPBYRPBPBYBYBYRPBPRYBPBYBPRPRYBPRPBYBPRPBYRPBYBPRYBPBPBYRYBYBYBPRYBYRPRPRPRPRYRYBPBPBPBPRPRYBYRYBPRPRPRPBYBPBPRYRPRPBYRPBYRYRPBYBYBPBYRYRPBPRYBPRYBPBPBYRPBPBYBYBPRPBYBYBYRYRPBPRPRPRPRPRYBPBPBPRYBYRPRPRYBYRPRPBYR...
output:
0
result:
ok 1 number(s): "0"
Test #12:
score: 0
Accepted
time: 3385ms
memory: 5576kb
input:
50000 YRPBPBYRYRYRYBYBYRPBPBPBPBPBYRYBPBPRYBPBYRYRPRYBYBYBYRPRPBPBPRYRPBYBYBPBYRYRPRPBPBPBPRYBYBYRYRPRPRYBPRPBYRPBPRYRPRYBPRYBYBYRYRYBYRYRYBYRPBPBPBYBPBPRPBPRYRPRYBYBPBPRPBPBPRPRPBYRYRPBPBPBYRPBYBYBYRPBPRPBPRYBPRPRYBPRPBPBYRYRYRYBYRPRPRYBYBYBPBPRPBPRYRYRPRPRPBPBPRPRPBYBYRPRPRPBYBYRPBYBPRPRPRPRPRPBPB...
output:
0
result:
ok 1 number(s): "0"
Test #13:
score: 0
Accepted
time: 3364ms
memory: 5620kb
input:
50000 PRPRYBPBYBYBPBYRPBYRYBPBPBPRPRPBYBYRPRPRPRPRPRYRYBYRPBPBPRYRPRPBPRPBPRPRPRPBYRYRYRPBYBYRYRPRPRPRPRYBYBYBYBPBPRPBPBPRYRPRYRPRPRYRPRPBPBYRYBPRPRYRPBPBYBYBPBYRPBPRYRPRYRYBPBPBPRPBPRPRPRYBPBPBYBYBPRYRPRYRPBYRYBYRYRPBYBPBPRPRYRPRYBYRPRPRYBYBYBPBYRYRYRYRYRYRPBYBYRYRYBYRPRYRPBPBYBYRYBPBYBPRYBPBYRYBPR...
output:
0
result:
ok 1 number(s): "0"
Test #14:
score: 0
Accepted
time: 3405ms
memory: 5460kb
input:
50000 YRPRPBPRYRYRPRYBPBYRPRPBYRYRYRPBPBYRPRYBYBYBPRYRPBPRPBPBYRPRPRPBPBYBYBPRPRPRYRYRYBYRPBYBPBPRYBPRYBYBYBPBYBYBPBPBPRYRPRPBYRYBYRPRYBYRPRYRPRPRYRPBYRYRYBYRYRPRYRYRPBPRPBYRYRPBYRPBPBPBPRPBYBYBPRYBPBPBYRYRYBYRPRPBPRYBPRPBYRPBYBYBPBPRPBYRYRPRPBPRPBPBYRPRPBYRPRPRYRYRPBYBYBPBPBYBPBYBYRYBYRPBPBPBPRYRPB...
output:
0
result:
ok 1 number(s): "0"
Test #15:
score: 0
Accepted
time: 3402ms
memory: 5452kb
input:
50000 YBPBYRPRYRPRPBPBYBYRPBYRPBPRPRPBPBPBYRYBYRPBYRYRPBYRPRPRYBPRYRYBYBPRPRYBYBPRPRPRYRPRYBPRPBYRPBYRPBYRPRPBPBPRPBPBYRYBPRPBPBPBPBYRYRPRPRYBYRPRYBYBYBYBYRYRPBPRYRYRPRYBPRPBPRPRPRPRPBPRPBYBPBPBPBYRPBYBPBPRPBYRPRPRYRYBYRPRPBPRYBYRPBPRPBPRYRPRYBYRYBYBPRPRPRPBYRPBPBYRYRPBPRYBPRYBPRYBPRYBYRPBYBPBPBYRPR...
output:
0
result:
ok 1 number(s): "0"
Test #16:
score: 0
Accepted
time: 53ms
memory: 4936kb
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: 53ms
memory: 5000kb
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: 53ms
memory: 5016kb
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: 57ms
memory: 4968kb
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: 56ms
memory: 5068kb
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: 34ms
memory: 4936kb
input:
5000 PRPBPRPRYRPRPBYBPBPBYRPBPBPBYRYRYBPBYRPRYBPBPRYBPBYRPRYBYRYRPBPBPBPBYRPBYRYBYRPRYBPBPBPRYBPRYBYBPRPBPBYRYBPRPBYRYRPRYBPRPRPBYRPBYRYRPRPRYRYRYBYBPBPBPBPRPRPBPRPRYRPBYRYRYRPBPRPRYRPRPBYBYBPBPRPRYRPBPRYBPRYBPRPRYRPRYRPBPRYBPRPRYBYRPBYRPRYBPRPRYBYRPRYRYBPRYBPRPBPRPRPRYBYRYRYRYRPBPRPBPRPBPRPBPRYRYBY...
output:
0
result:
ok 1 number(s): "0"
Test #22:
score: 0
Accepted
time: 35ms
memory: 5032kb
input:
5000 PRYRYBPBPRYRYRYRPBPBYBYRPBPBYRPRPRYBYRPRYRPBPRYBPBYRPRYRYRYBPBPBYBPBYBPBYRYRYRYRYBYRPRPBYRYBPRYBYBPRPRPBYRYRYRPBYBPBPRPRYRPRPBPRYBYBPBPBYBPBPBPRPBYRYRYRYRPRYBYBPBYBYBPBYBYRPRYRPRPRYBYRYBYRYRYBYBYRPBPRYRYRPRPRPRPRYRPRYRYRPBYBYRPBYBPBPRYBPBYBPBPRYRYRPBPRPRPBPRYRPRYBPBYRPRYBPBYRYBPRPRYRYBYBPRPBYBP...
output:
0
result:
ok 1 number(s): "0"
Test #23:
score: 0
Accepted
time: 31ms
memory: 5024kb
input:
5000 PBYRYRYBYBPBYBYBPBYBYRPRYBYRPRPBYRYBPRYBPRPRYRYRPBYRYRPRYRYBPBYBPBPRPBPRPBPBP?YRPBYBYBPRPRPBPRYRPRYBPRYRYBYRPRYBYBPBYRPBPBYBYRYBPRPBYRYBPBYBYRYRYRPRPRYBYBPRYRPRYBYBYBPRYBPBYRYBPBPRPRPBYBYRYBYRPRYBYBYBYBYBPBYRPRPRPRPRYBYRPRYRYRYBYRPBYRPBPRPRYBPBYBYRPRYBPRYBPRPRPRPBYRPRPBYRYBY?PRYRYRYBPRYRYBYRYBY...
output:
172032
result:
ok 1 number(s): "172032"
Test #24:
score: 0
Accepted
time: 68ms
memory: 5028kb
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: 102ms
memory: 5144kb
input:
5000 ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...
output:
312356960
result:
ok 1 number(s): "312356960"
Test #26:
score: 0
Accepted
time: 5230ms
memory: 5460kb
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: 5255ms
memory: 5456kb
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: 5197ms
memory: 5460kb
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: 5247ms
memory: 5584kb
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: 5284ms
memory: 5400kb
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: 3459ms
memory: 5452kb
input:
50000 PBYRYRYBYRYBYRPBYRPBPBYBYRYBYBPRPBYRYRYBYRPBPRYBYRYRYRYBYRYRYRPRYBYRPRPRPRYRPBYRPRPBYRPBYRYRPBYRYBPRYRPRYBYBYRYBPRPBYBPRPRPRYRPRYRPRYRPBYBPRPRYRYRPRPRPBYRYRYRPRPBPRPRYRYRYBYRYRYRPBYBYRPBPBYRPRPBPRYBPRPBYBPBPBPBYRYRPRPBYRPBYRYBPRPBYRYBPBPRPRPBYBPRYRPBYBYBYRPRYBYBYBPBYBPBPRYRYRYRPRYBYBYBPBPBYBPR...
output:
0
result:
ok 1 number(s): "0"
Test #32:
score: 0
Accepted
time: 3417ms
memory: 5460kb
input:
50000 PRYRPBPRYRYBYRYBYRYRYRPRPBPRPRYBYBPBYRPRYRYRYRYRPBYBPRPRPRPRPRPRYBPRPBYBPBYBYBYRPRPBYBYBYBYBPRPBYBPBPRYRYBYBPBYRYBYRPBYRYRYRYBYBYRYBYRPRPBPBPBPBPBPRPRYBYRYRPBPRPRYBYRPRYRYRYRYRPRPRYRPBPRYRYRPBYBPRPBYRYRYBYRYBPRYBYRYRPRYBYBPRPBYRPBYBYRYRYRYBPBPRPBYBPBYRYBYRPBPBYBPRYBYRYBPBYRYRPBYBPBYBPRPBYBYRYB...
output:
0
result:
ok 1 number(s): "0"
Test #33:
score: 0
Accepted
time: 3367ms
memory: 5628kb
input:
50000 PBPRPBYRPRYBYBYRPBPBYRPBPRPBPBPBYRPBYBYRPRYBPRPRYRYBPBPBYRPRYRYRPBYRYRPBPBYRPBPBYRPBYRYBYRYBYBYRYBPRPBYRYRYRPBYRPBYBPRYRYBPRYBYBYRPBPRYRYRYBYRPBPBPBPBPRYBYRPBYBYRYRYBYRYRYBYRPRYRPBYRPBPRYBYRPBPBYRYRPRYRYRYBPBYRPRPRPBPRPRYRPBPBYBPBPBYBYBYBPBYBPRPBYBYRPRPBYBPRPBPRPBYRPBPRYRPRYRYRYBPRPRPRYRPBYBPR...
output:
0
result:
ok 1 number(s): "0"
Test #34:
score: 0
Accepted
time: 6455ms
memory: 5584kb
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: 2ms
memory: 5084kb
input:
50000 ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...
output:
422064317
result:
ok 1 number(s): "422064317"