QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#429880 | #8776. Not Another Constructive! | skittles1412# | AC ✓ | 48ms | 159584kb | C++17 | 9.2kb | 2024-06-03 00:30:38 | 2024-06-03 00:30:38 |
Judging History
answer
// cf bits/extc++.h nonsense
#ifdef ONLINE_JUDGE
#define _EXT_CODECVT_SPECIALIZATIONS_H 1
#define _EXT_ENC_FILEBUF_H 1
#endif
#line 1 "i.cpp"
// 69683a8183e36171b0123a3fbef815656276c8d9
#include "bits/extc++.h"
#line 1 "/home/skittles1412/workspace/cp/library/template.hpp"
#line 5 "/home/skittles1412/workspace/cp/library/template.hpp"
using namespace std;
template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
cerr << t;
((cerr << " | " << u), ...);
cerr << endl;
}
#ifdef DEBUG
#define dbg(...) \
cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]" \
<< ": "; \
dbgh(__VA_ARGS__)
#else
#define cerr \
if (false) \
cerr
#define dbg(...)
#endif
using u32 = uint32_t;
using u64 = uint64_t;
using ld = long double;
#define endl "\n"
#define long int64_t
#define sz(x) int(std::size(x))
#line 1 "/home/skittles1412/workspace/cp/library/utils.hpp"
#line 5 "/home/skittles1412/workspace/cp/library/utils.hpp"
template <typename T>
ostream& operator<<(ostream& out, const vector<T>& arr) {
out << "[";
for (int i = 0; i < sz(arr); i++) {
if (i) {
out << ", ";
}
out << arr[i];
}
return out << "]";
}
template <typename T, size_t N>
ostream& operator<<(ostream& out, const array<T, N>& arr) {
out << "[";
for (size_t i = 0; i < N; i++) {
if (i) {
out << ", ";
}
out << arr[i];
}
return out << "]";
}
template <typename A, typename B>
ostream& operator<<(ostream& out, const pair<A, B>& p) {
return out << "(" << p.first << ", " << p.second << ")";
}
/**
* Computes the first x in [l, r) such that cb(x) is true.
*
* If no x in that range is true, returns r
*/
template <typename T, typename Cb>
T first_true(T l, T r, const Cb& cb) {
while (l < r) {
T mid = (l + r) / 2;
if (cb(mid)) {
r = mid;
} else {
l = mid + 1;
}
}
return l;
}
/**
* Computes the last x in (l, r] such that cb(x) is true.
*
* If no x in that range is true, returns l
*/
template <typename T, typename Cb>
T last_true(T l, T r, const Cb& cb) {
while (l < r) {
T mid = (l + r + 1) / 2;
if (cb(mid)) {
l = mid;
} else {
r = mid - 1;
}
}
return l;
}
template <typename T>
T reversed(T arr) {
reverse(begin(arr), end(arr));
return arr;
}
template <typename T>
bool is_palin(const T& arr) {
return arr == reversed(arr);
}
template <typename T>
T sorted(T arr) {
sort(begin(arr), end(arr));
return arr;
}
template <typename T>
T negated(T arr) {
for (auto& a : arr) {
a = -a;
}
return arr;
}
template <typename T, bool STRICT>
vector<int> comp_prev_helper(const vector<T>& arr) {
int n = sz(arr);
vector<int> ans(n);
vector<pair<int, int>> st;
for (int i = 0; i < n; i++) {
auto cmp = [&]() -> bool {
if constexpr (STRICT) {
return st.back().first <= arr[i];
} else {
return st.back().first < arr[i];
}
};
while (sz(st) && cmp()) {
st.pop_back();
}
if (sz(st)) {
ans[i] = st.back().second;
} else {
ans[i] = -1;
}
st.emplace_back(arr[i], i);
}
return ans;
}
/**
* Computes ans[i], the closest index j to the left of i where arr[j] > arr[i]
*
* ans[i] = -1 if no such j exists
*/
template <typename T>
vector<int> comp_prev_gt(const vector<T>& arr) {
return comp_prev_helper<T, true>(arr);
}
/**
* Computes ans[i], the closest index j to the left of i where arr[j] >= arr[i]
*
* ans[i] = -1 if no such j exists
*/
template <typename T>
vector<int> comp_prev_ge(const vector<T>& arr) {
return comp_prev_helper<T, false>(arr);
}
/**
* reverses an array of indices
*
* specifically, it reverses the array and computes arr[i] = n - 1 - arr[i]
*/
vector<int> reverse_indices(vector<int> arr) {
int n = sz(arr);
reverse(begin(arr), end(arr));
for (auto& a : arr) {
a = n - 1 - a;
}
return arr;
}
/**
* Computes ans[i], the closest index j to the right of i where arr[j] > arr[i]
*
* ans[i] = n if no such j exists
*/
template <typename T>
vector<int> comp_next_gt(vector<T> arr) {
reverse(begin(arr), end(arr));
return reverse_indices(comp_prev_gt(arr));
}
/**
* Computes ans[i], the closest index j to the right of i where arr[j] >= arr[i]
*
* ans[i] = n if no such j exists
*/
template <typename T>
vector<int> comp_next_ge(vector<T> arr) {
reverse(begin(arr), end(arr));
return reverse_indices(comp_prev_ge(arr));
}
template <typename Cb>
struct CmpByKey {
Cb cb;
explicit CmpByKey(const Cb& cb) : cb(cb) {}
template <typename T>
bool operator()(const T& a, const T& b) const {
return cb(a) < cb(b);
}
};
/**
* outputs will be in the range [0, m), returns m
*/
int coord_comp(const vector<int*>& arr) {
vector<int> vals;
for (auto& a : arr) {
vals.push_back(*a);
}
sort(begin(vals), end(vals));
vals.erase(unique(begin(vals), end(vals)), end(vals));
for (auto& a : arr) {
*a = int(lower_bound(begin(vals), end(vals), *a) - begin(vals));
}
return sz(vals);
}
/**
* outputs will be in the range [0, m), returns {m, result}
*/
template <typename T>
pair<int, vector<int>> coord_comp(const vector<T>& arr) {
vector<T> vals = arr;
sort(begin(vals), end(vals));
vals.erase(unique(begin(vals), end(vals)), end(vals));
vector<int> ans;
for (auto& a : arr) {
ans.push_back(
int(lower_bound(begin(vals), end(vals), a) - begin(vals)));
}
return {sz(vals), ans};
}
template <typename T>
bool on(T mask, int bit) {
return (mask >> bit) & 1;
}
#line 5 "i.cpp"
constexpr int MAXN = 43, MAXK = 2505;
bool dp[MAXN][MAXN][MAXN][MAXK];
void solve() {
int n, m;
string s;
cin >> n >> m >> s;
for (int cn = 0; cn <= n; cn++) {
dp[n][cn][0][m] = true;
}
for (int i = n - 1; i >= 0; i--) {
for (int cn = 0; cn <= i; cn++) {
for (int cc = 0; cc <= n - i; cc++) {
for (int cm = 0; cm <= m; cm++) {
auto& cdp = dp[i][cn][cc][cm];
auto go = [&](char c) -> void {
if (c == 'N') {
cdp |= dp[i + 1][cn + 1][cc][cm];
} else if (c == 'A') {
if (cm + cn * cc <= m) {
cdp |= dp[i + 1][cn][cc][cm + cn * cc];
}
} else if (c == 'C') {
if (cc) {
cdp |= dp[i + 1][cn][cc - 1][cm];
}
} else {
cdp |= dp[i + 1][cn][cc][cm];
}
};
if (s[i] == '?') {
go('N');
go('A');
go('C');
go('B');
} else {
go(s[i]);
}
}
}
}
}
int i = 0, cn = 0, cc = -1, cm = 0;
for (int j = 0; j <= n; j++) {
if (dp[i][cn][j][cm]) {
cc = j;
}
}
if (cc == -1) {
cout << -1 << endl;
return;
}
while (i < n) {
bool found = false;
auto go = [&](char c) -> void {
if (found) {
return;
}
if (c == 'N') {
if (dp[i + 1][cn + 1][cc][cm]) {
i++;
cn++;
found = true;
cout << c;
}
} else if (c == 'A') {
if (cm + cn * cc <= m && dp[i + 1][cn][cc][cm + cn * cc]) {
i++;
cm += cn * cc;
found = true;
cout << c;
}
} else if (c == 'C') {
if (cc && dp[i + 1][cn][cc - 1][cm]) {
i++;
cc--;
found = true;
cout << c;
}
} else {
if (dp[i + 1][cn][cc][cm]) {
i++;
found = true;
cout << c;
}
}
};
if (s[i] == '?') {
go('N');
go('A');
go('C');
go('B');
} else {
go(s[i]);
}
assert(found);
}
cout << endl;
}
int main() {
cin.tie(nullptr);
cin.exceptions(ios::failbit);
ios_base::sync_with_stdio(false);
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 21308kb
input:
22 2 N??A??????C???????????
output:
NCCANNNNNNCNNNNNNNNNNC
result:
ok correct
Test #2:
score: 0
Accepted
time: 3ms
memory: 59140kb
input:
18 0 COUNTINGSATELLITES
output:
COUNTINGSATELLITES
result:
ok correct
Test #3:
score: 0
Accepted
time: 1ms
memory: 5892kb
input:
2 1 ??
output:
-1
result:
ok correct
Test #4:
score: 0
Accepted
time: 0ms
memory: 5608kb
input:
1 0 ?
output:
C
result:
ok correct
Test #5:
score: 0
Accepted
time: 0ms
memory: 5628kb
input:
1 0 N
output:
N
result:
ok correct
Test #6:
score: 0
Accepted
time: 1ms
memory: 5808kb
input:
1 0 X
output:
X
result:
ok correct
Test #7:
score: 0
Accepted
time: 1ms
memory: 5604kb
input:
1 1 ?
output:
-1
result:
ok correct
Test #8:
score: 0
Accepted
time: 1ms
memory: 5804kb
input:
1 1 N
output:
-1
result:
ok correct
Test #9:
score: 0
Accepted
time: 1ms
memory: 5808kb
input:
1 1 X
output:
-1
result:
ok correct
Test #10:
score: 0
Accepted
time: 1ms
memory: 5692kb
input:
2 0 ??
output:
CC
result:
ok correct
Test #11:
score: 0
Accepted
time: 1ms
memory: 5820kb
input:
2 0 N?
output:
NC
result:
ok correct
Test #12:
score: 0
Accepted
time: 1ms
memory: 7688kb
input:
2 0 ?C
output:
CC
result:
ok correct
Test #13:
score: 0
Accepted
time: 0ms
memory: 5864kb
input:
2 1 N?
output:
-1
result:
ok correct
Test #14:
score: 0
Accepted
time: 0ms
memory: 7652kb
input:
2 1 ?C
output:
-1
result:
ok correct
Test #15:
score: 0
Accepted
time: 1ms
memory: 5672kb
input:
3 1 ???
output:
NAC
result:
ok correct
Test #16:
score: 0
Accepted
time: 0ms
memory: 5672kb
input:
3 1 N??
output:
NAC
result:
ok correct
Test #17:
score: 0
Accepted
time: 1ms
memory: 7668kb
input:
3 1 ?A?
output:
NAC
result:
ok correct
Test #18:
score: 0
Accepted
time: 1ms
memory: 10008kb
input:
3 1 ??C
output:
NAC
result:
ok correct
Test #19:
score: 0
Accepted
time: 0ms
memory: 10004kb
input:
3 1 NA?
output:
NAC
result:
ok correct
Test #20:
score: 0
Accepted
time: 1ms
memory: 7884kb
input:
3 1 N?C
output:
NAC
result:
ok correct
Test #21:
score: 0
Accepted
time: 1ms
memory: 9672kb
input:
3 1 ?AC
output:
NAC
result:
ok correct
Test #22:
score: 0
Accepted
time: 1ms
memory: 5656kb
input:
4 1 ????
output:
NCAC
result:
ok correct
Test #23:
score: 0
Accepted
time: 1ms
memory: 5684kb
input:
4 1 X???
output:
XNAC
result:
ok correct
Test #24:
score: 0
Accepted
time: 1ms
memory: 9820kb
input:
4 1 ???Z
output:
NACZ
result:
ok correct
Test #25:
score: 0
Accepted
time: 1ms
memory: 11800kb
input:
4 1 ?AA?
output:
-1
result:
ok correct
Test #26:
score: 0
Accepted
time: 1ms
memory: 5684kb
input:
4 1 N???
output:
NCAC
result:
ok correct
Test #27:
score: 0
Accepted
time: 1ms
memory: 10040kb
input:
4 1 ?N??
output:
CNAC
result:
ok correct
Test #28:
score: 0
Accepted
time: 0ms
memory: 7812kb
input:
4 1 ??N?
output:
NANC
result:
ok correct
Test #29:
score: 0
Accepted
time: 0ms
memory: 7700kb
input:
4 1 ???N
output:
NACN
result:
ok correct
Test #30:
score: 0
Accepted
time: 1ms
memory: 5968kb
input:
4 1 A???
output:
ANAC
result:
ok correct
Test #31:
score: 0
Accepted
time: 0ms
memory: 7736kb
input:
4 1 ?A??
output:
NANC
result:
ok correct
Test #32:
score: 0
Accepted
time: 1ms
memory: 9828kb
input:
4 1 ??A?
output:
NCAC
result:
ok correct
Test #33:
score: 0
Accepted
time: 1ms
memory: 9768kb
input:
4 1 ???A
output:
NACA
result:
ok correct
Test #34:
score: 0
Accepted
time: 1ms
memory: 9780kb
input:
4 1 C???
output:
CNAC
result:
ok correct
Test #35:
score: 0
Accepted
time: 1ms
memory: 7916kb
input:
4 1 ?C??
output:
NCAC
result:
ok correct
Test #36:
score: 0
Accepted
time: 0ms
memory: 10036kb
input:
4 1 ??C?
output:
NACN
result:
ok correct
Test #37:
score: 0
Accepted
time: 0ms
memory: 7984kb
input:
4 1 ???C
output:
NCAC
result:
ok correct
Test #38:
score: 0
Accepted
time: 0ms
memory: 6020kb
input:
5 4 ?????
output:
NNACC
result:
ok correct
Test #39:
score: 0
Accepted
time: 0ms
memory: 6060kb
input:
6 14 ??????
output:
-1
result:
ok correct
Test #40:
score: 0
Accepted
time: 0ms
memory: 6192kb
input:
7 14 ???????
output:
-1
result:
ok correct
Test #41:
score: 0
Accepted
time: 0ms
memory: 8284kb
input:
8 43 ????????
output:
-1
result:
ok correct
Test #42:
score: 0
Accepted
time: 1ms
memory: 8312kb
input:
9 55 ?????????
output:
-1
result:
ok correct
Test #43:
score: 0
Accepted
time: 1ms
memory: 8408kb
input:
10 112 ??????????
output:
-1
result:
ok correct
Test #44:
score: 0
Accepted
time: 1ms
memory: 6568kb
input:
11 110 ???????????
output:
-1
result:
ok correct
Test #45:
score: 0
Accepted
time: 1ms
memory: 8860kb
input:
12 4 ????????????
output:
NCCCCCCACCCC
result:
ok correct
Test #46:
score: 0
Accepted
time: 2ms
memory: 9340kb
input:
13 193 ?????????????
output:
-1
result:
ok correct
Test #47:
score: 0
Accepted
time: 2ms
memory: 9448kb
input:
14 91 ??????????????
output:
NNNANAAACACCCC
result:
ok correct
Test #48:
score: 0
Accepted
time: 0ms
memory: 7744kb
input:
15 15 ???????????????
output:
NACCCCCCCCCACCC
result:
ok correct
Test #49:
score: 0
Accepted
time: 2ms
memory: 8240kb
input:
16 261 ????????????????
output:
-1
result:
ok correct
Test #50:
score: 0
Accepted
time: 3ms
memory: 10664kb
input:
17 514 ?????????????????
output:
-1
result:
ok correct
Test #51:
score: 0
Accepted
time: 0ms
memory: 9180kb
input:
18 678 ??????????????????
output:
-1
result:
ok correct
Test #52:
score: 0
Accepted
time: 3ms
memory: 9588kb
input:
19 40 ???????????????????
output:
NNACCCCCCCCCCACCCCC
result:
ok correct
Test #53:
score: 0
Accepted
time: 5ms
memory: 12708kb
input:
20 1019 ????????????????????
output:
-1
result:
ok correct
Test #54:
score: 0
Accepted
time: 3ms
memory: 13388kb
input:
21 1218 ?????????????????????
output:
-1
result:
ok correct
Test #55:
score: 0
Accepted
time: 4ms
memory: 16236kb
input:
22 1348 ??????????????????????
output:
-1
result:
ok correct
Test #56:
score: 0
Accepted
time: 0ms
memory: 16532kb
input:
23 476 ???????????????????????
output:
-1
result:
ok correct
Test #57:
score: 0
Accepted
time: 3ms
memory: 15568kb
input:
24 1445 ????????????????????????
output:
-1
result:
ok correct
Test #58:
score: 0
Accepted
time: 7ms
memory: 18860kb
input:
25 1331 ?????????????????????????
output:
-1
result:
ok correct
Test #59:
score: 0
Accepted
time: 0ms
memory: 19248kb
input:
26 459 ??????????????????????????
output:
NNNNNNNNNAAACACCCCCCCCCCCC
result:
ok correct
Test #60:
score: 0
Accepted
time: 0ms
memory: 20572kb
input:
27 398 ???????????????????????????
output:
NNNNANAAACCACCCCCCCCCCCCCCC
result:
ok correct
Test #61:
score: 0
Accepted
time: 4ms
memory: 19344kb
input:
28 274 ????????????????????????????
output:
NNANAAACCACCCCCCCCCCCCCCCCCC
result:
ok correct
Test #62:
score: 0
Accepted
time: 10ms
memory: 23116kb
input:
29 1624 ?????????????????????????????
output:
-1
result:
ok correct
Test #63:
score: 0
Accepted
time: 11ms
memory: 24712kb
input:
30 2079 ??????????????????????????????
output:
-1
result:
ok correct
Test #64:
score: 0
Accepted
time: 8ms
memory: 26032kb
input:
31 2067 ???????????????????????????????
output:
-1
result:
ok correct
Test #65:
score: 0
Accepted
time: 10ms
memory: 25060kb
input:
32 1267 ????????????????????????????????
output:
-1
result:
ok correct
Test #66:
score: 0
Accepted
time: 16ms
memory: 28464kb
input:
33 928 ?????????????????????????????????
output:
NNNNNNNNAAAAAACCCCCCCCCCACCCCCCCC
result:
ok correct
Test #67:
score: 0
Accepted
time: 0ms
memory: 27732kb
input:
34 298 ??????????????????????????????????
output:
NNNNAANCCCCCCCCACCCCCCCCCCCCCCCCCC
result:
ok correct
Test #68:
score: 0
Accepted
time: 33ms
memory: 32680kb
input:
35 2361 ???????????????????????????????????
output:
-1
result:
ok correct
Test #69:
score: 0
Accepted
time: 11ms
memory: 31268kb
input:
36 489 ????????????????????????????????????
output:
NNNNCANAACACCCCCCCCCCCCCCCCCCCCCCCCC
result:
ok correct
Test #70:
score: 0
Accepted
time: 11ms
memory: 33056kb
input:
37 294 ?????????????????????????????????????
output:
NNNANACCCCCCCCCACCCCCCCCCCCCCCCCCCCCC
result:
ok correct
Test #71:
score: 0
Accepted
time: 19ms
memory: 37816kb
input:
38 1558 ??????????????????????????????????????
output:
NNNNNNNNNNNAANAAAAACCCCCCCCCCCCCCCCCCC
result:
ok correct
Test #72:
score: 0
Accepted
time: 24ms
memory: 39832kb
input:
39 1319 ???????????????????????????????????????
output:
NNNNNNNNACAANAAACACCCCCCCCCCCCCCCCCCCCC
result:
ok correct
Test #73:
score: 0
Accepted
time: 15ms
memory: 42024kb
input:
40 993 ????????????????????????????????????????
output:
NNNNNNAACAANACACCCCCCCCCCCCCCCCCCCCCCCCC
result:
ok correct
Test #74:
score: 0
Accepted
time: 8ms
memory: 155832kb
input:
40 498 ACNANACNNACNACNNNCNCNNNANNNACNCCACAA?ANA
output:
-1
result:
ok correct
Test #75:
score: 0
Accepted
time: 25ms
memory: 159584kb
input:
40 855 NAAANAACNNNCNAANCNANCNANACANCCAANCACNCAC
output:
-1
result:
ok correct
Test #76:
score: 0
Accepted
time: 11ms
memory: 154260kb
input:
40 1007 ?CNACNNAANACANACNACCC?CAANNCCCCANNANCACN
output:
-1
result:
ok correct
Test #77:
score: 0
Accepted
time: 30ms
memory: 154444kb
input:
40 1778 NACANANN?CCANNCCAACNNCCNCCCNCCNACCNC?NNN
output:
-1
result:
ok correct
Test #78:
score: 0
Accepted
time: 25ms
memory: 148700kb
input:
40 2186 ACCCACAN?NNA?AACCNNNN?ANACCANCNCNNCA?NCN
output:
-1
result:
ok correct
Test #79:
score: 0
Accepted
time: 0ms
memory: 143328kb
input:
40 332 ACAC?NCCCANAA?ACCNNC?NAC?CAC?CNCNNACNNNN
output:
-1
result:
ok correct
Test #80:
score: 0
Accepted
time: 15ms
memory: 151940kb
input:
40 712 ANCNANAAC?CACAACA?CNACCCANAACCA?CNNAANCN
output:
-1
result:
ok correct
Test #81:
score: 0
Accepted
time: 19ms
memory: 154452kb
input:
40 1127 C?CAAAANNCANANAC?NCANACANAACAACANNCCNCAC
output:
-1
result:
ok correct
Test #82:
score: 0
Accepted
time: 42ms
memory: 149280kb
input:
40 1835 CANNCAANNNAANANNCACANAC?CCCCAACA?NNNCAC?
output:
-1
result:
ok correct
Test #83:
score: 0
Accepted
time: 32ms
memory: 156772kb
input:
40 2009 CANAAAN?ANAACNCCNCCNCAAANCANCCAN?CCNCAAN
output:
-1
result:
ok correct
Test #84:
score: 0
Accepted
time: 3ms
memory: 134824kb
input:
40 54 CNAC?ACAAC?ACC?ANC?C?NNCAANCCAC?NCN?CACA
output:
-1
result:
ok correct
Test #85:
score: 0
Accepted
time: 20ms
memory: 131244kb
input:
40 955 ?A?ANA?NN?C?ANC??CNNACAAC?N?AAN?AN??ANNA
output:
-1
result:
ok correct
Test #86:
score: 0
Accepted
time: 19ms
memory: 118408kb
input:
40 1451 ??CCCA?N?ACCN?C???NNN??C?ANAN??NCNA??NAN
output:
-1
result:
ok correct
Test #87:
score: 0
Accepted
time: 23ms
memory: 134884kb
input:
40 1526 CN??AC?CCCCNACCNCNCCNC?CAAN?C?CA??ANCN?A
output:
-1
result:
ok correct
Test #88:
score: 0
Accepted
time: 32ms
memory: 143200kb
input:
40 2453 C?NC?CCAAN?ACCCNCC??ACAANCANCNCNNAACC?NN
output:
-1
result:
ok correct
Test #89:
score: 0
Accepted
time: 4ms
memory: 125608kb
input:
40 166 ?NC??AACAN??NCA?CCAA?A??CNNN?ACNN?AN?ANC
output:
CNCCCAACANCCNCACCCAACACCCNNNBACNNCANBANC
result:
ok correct
Test #90:
score: 0
Accepted
time: 16ms
memory: 107292kb
input:
40 887 ?NA?AN?N?A?ANN??N?ANCAN?N????AC?NN?NA???
output:
NNANANNNNANANNCCNAANCANANCCCCACCNNCNACCC
result:
ok correct
Test #91:
score: 0
Accepted
time: 20ms
memory: 126636kb
input:
40 1310 CCN?NNANC??CANN??NC?N??NA?NNNNCN?N?CCCCC
output:
-1
result:
ok correct
Test #92:
score: 0
Accepted
time: 24ms
memory: 127352kb
input:
40 1568 ANCN?N?NACC??NNN?AAC?AANA?CA?NC?CNNAN??N
output:
-1
result:
ok correct
Test #93:
score: 0
Accepted
time: 27ms
memory: 119076kb
input:
40 2035 CA?N?ACCNN??CANA?NC?NACNC??CC???NCA?N?AC
output:
-1
result:
ok correct
Test #94:
score: 0
Accepted
time: 0ms
memory: 111384kb
input:
40 126 AC?CACCCN???C?NCCN?NN??CN?CNCN?C?N?C?A?C
output:
ACNCACCCNCACCCNCCNCNNCCCNCCNCNCCANCCCACC
result:
ok correct
Test #95:
score: 0
Accepted
time: 16ms
memory: 96916kb
input:
40 962 CCC???A??????AN?N???C?NN??CANA?CNA??N???
output:
CCCNNNANNNNNNANANAAACCNNCACANAACNACCNCCC
result:
ok correct
Test #96:
score: 0
Accepted
time: 19ms
memory: 121192kb
input:
40 1043 ?A??NANA?CN?N?AN?ANN?CNAANCC??AAANNN????
output:
-1
result:
ok correct
Test #97:
score: 0
Accepted
time: 20ms
memory: 105532kb
input:
40 1638 N?ANA?NA???A??N?CNNAA???NC????CNN??AC??N
output:
-1
result:
ok correct
Test #98:
score: 0
Accepted
time: 41ms
memory: 109664kb
input:
40 2240 NNC??NCA???N?N?NNC??CNNNAN??C?AN??AC?C??
output:
-1
result:
ok correct
Test #99:
score: 0
Accepted
time: 3ms
memory: 98056kb
input:
40 55 N?NCNC????C?A??A?A?NN??ACC??C??NC???ACN?
output:
-1
result:
ok correct
Test #100:
score: 0
Accepted
time: 11ms
memory: 93332kb
input:
40 639 C???NN??C?N?N????N?CA?NCAN????AN????NA??
output:
CNNNNNNACANCNCCCCNACACNCANCCCCANCCCCNACC
result:
ok correct
Test #101:
score: 0
Accepted
time: 30ms
memory: 108968kb
input:
40 1438 ?C?A?NA?AN???CA???NAAAN??A?NNANNCAA?????
output:
-1
result:
ok correct
Test #102:
score: 0
Accepted
time: 20ms
memory: 107964kb
input:
40 1660 ???C?A???????NN??AANNAC???A?CN??ACN?AC?C
output:
-1
result:
ok correct
Test #103:
score: 0
Accepted
time: 27ms
memory: 83612kb
input:
40 2016 ??AA??N?N??A?C?C????????C????C?C?CN??N?A
output:
-1
result:
ok correct
Test #104:
score: 0
Accepted
time: 8ms
memory: 97108kb
input:
40 242 ?C???A???AA??A??C?CN???C???A?ANA?NN??AA?
output:
NCNACACCCAACCACCCCCNCCCCCCCABANACNNCCAAC
result:
ok correct
Test #105:
score: 0
Accepted
time: 16ms
memory: 78668kb
input:
40 711 ??A?AA?C??C???CCNA?????C????A?????A??C??
output:
NNANAANCNACACCCCNACCCCCCCACCACCCCCACCCCC
result:
ok correct
Test #106:
score: 0
Accepted
time: 28ms
memory: 85256kb
input:
40 1094 ??AACN??N?A?????C????AA??CC???CC?N?A????
output:
NNAACNNNNNAANAACCCCACAACCCCCCACCCNCACCCC
result:
ok correct
Test #107:
score: 0
Accepted
time: 35ms
memory: 109252kb
input:
40 1878 ?A??AACCA????N???A???C?C?C??C?NANC?N?NAC
output:
-1
result:
ok correct
Test #108:
score: 0
Accepted
time: 35ms
memory: 92064kb
input:
40 2082 AC??ACANC?CN?C?N???C?N???N??C?CC?????C?C
output:
-1
result:
ok correct
Test #109:
score: 0
Accepted
time: 7ms
memory: 91156kb
input:
40 268 N?N??NNNCNC??CAC????A?C?????N???AN??NC??
output:
NCNCCNNNCNCCCCACCCCCACCCCCCCNCCAANCCNCCC
result:
ok correct
Test #110:
score: 0
Accepted
time: 24ms
memory: 71996kb
input:
40 960 ?????????N???NA?????????C??AC???AN?A???A
output:
NNNNNNNACNAACNACCACCCCCCCCAACCCCANCACCCA
result:
ok correct
Test #111:
score: 0
Accepted
time: 16ms
memory: 77632kb
input:
40 1342 ???C?????C?????NA?N??N?C?????A?N???NA???
output:
NNNCNNNNNCNAAANNAANAANACAACCCACNCCCNACCC
result:
ok correct
Test #112:
score: 0
Accepted
time: 19ms
memory: 87516kb
input:
40 1739 ?A?A???A???N?A??N???C???NCC??C??ANN???A?
output:
-1
result:
ok correct
Test #113:
score: 0
Accepted
time: 32ms
memory: 63916kb
input:
40 2484 ??????N????N?????N?C??N????????????A???N
output:
-1
result:
ok correct
Test #114:
score: 0
Accepted
time: 4ms
memory: 55464kb
input:
40 116 ?CN????????A??A???C????????????????C????
output:
NCNCCCCCCCCACCACCCCCCCCCCCCCCCCACCCCCCCC
result:
ok correct
Test #115:
score: 0
Accepted
time: 12ms
memory: 66328kb
input:
40 538 NC???N?????????????NN??N????????CC???N??
output:
NCNNNNNAACCCCCCCCCCNNCANACCCCCCCCCCCCNCC
result:
ok correct
Test #116:
score: 0
Accepted
time: 20ms
memory: 63420kb
input:
40 1128 ?????AN?????CN????N?A????C???C??????????
output:
NNNNNANNACAACNACCCNAACCCCCCCCCCCCCCCCCCC
result:
ok correct
Test #117:
score: 0
Accepted
time: 32ms
memory: 65704kb
input:
40 1819 ?????????C?AC?????C??A??NC?????????????C
output:
-1
result:
ok correct
Test #118:
score: 0
Accepted
time: 34ms
memory: 69812kb
input:
40 2198 ??????A???N????????ANN???N?C??????C?????
output:
-1
result:
ok correct
Test #119:
score: 0
Accepted
time: 15ms
memory: 56656kb
input:
40 373 ???????????C?A?????????A???A?C??????????
output:
NNNANCCCCCCCCACCCACCCCCACCCACCCCCCCCCCCC
result:
ok correct
Test #120:
score: 0
Accepted
time: 15ms
memory: 55384kb
input:
40 744 ?????????????????C????????????A????C???N
output:
NNNNNNAANACCACCCCCCCCCCCCCCCCCACCCCCCCCN
result:
ok correct
Test #121:
score: 0
Accepted
time: 11ms
memory: 44932kb
input:
40 1103 ???????????????????????????N????????????
output:
NNNNNNNANAAAACCCCCCCCCACCCCNCCCCCCCCCCCC
result:
ok correct
Test #122:
score: 0
Accepted
time: 28ms
memory: 53188kb
input:
40 1866 ???????A??????A??A???????????????C??????
output:
NNNNNNNANANAAAAAAAACCCCCCACCCCCCCCCCCCCC
result:
ok correct
Test #123:
score: 0
Accepted
time: 48ms
memory: 59276kb
input:
40 2466 ????????????CN?????????????????N??CA????
output:
-1
result:
ok correct
Test #124:
score: 0
Accepted
time: 0ms
memory: 54232kb
input:
40 1 ?????????????????????????????????????NAC
output:
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCNAC
result:
ok correct