QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#429242#8776. Not Another Constructive!ucup-team2000#AC ✓568ms175112kbC++234.7kb2024-06-02 06:03:292024-06-02 06:03:30

Judging History

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

  • [2024-06-02 06:03:30]
  • 评测
  • 测评结果:AC
  • 用时:568ms
  • 内存:175112kb
  • [2024-06-02 06:03:29]
  • 提交

answer

#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>

int N, K;
char str[1000];
std::vector<unsigned long long> dp[50];
long long st[50][50][50 * 50];

int main() {
    for (int i = 0; i < 50; ++i)
        for (int j = 0; j < 50; ++j)
            for (int k = 0; k < 50 * 50; ++k) st[i][j][k] = -1;
    scanf("%d%d", &N, &K);
    scanf(" %s", str);
    {
        long long cnt = 0, a = 0, b = 0, c = 0;
        for (int i = 0; i < N; ++i) {
            cnt += str[i] == '?';
            a += str[i] == 'N';
            if (str[i] == 'A') {
                b += a;
            }
            if (str[i] == 'C') {
                c += b;
            }
        }
        long long rem = cnt;
        while ((rem / 3) * ((rem + 1) / 3) * ((rem + 2) / 3) + c >= K) --rem;
        long long diff = cnt - rem - 2;
        if (diff > 0)
            for (int i = 0; i < N; ++i) {
                if (str[i] == '?') {
                    str[i] = 'B';
                    --diff;
                    if (diff == 0) {
                        break;
                    }
                }
            }
    }
    // printf("::%lld\n", rem);
    dp[0].push_back(0);
    for (int i = 0; i < N; ++i) {
        dp[i + 1].reserve(dp[i].size() * 4);
        std::sort(dp[i].begin(), dp[i].end());
        // printf("%d: %d\n", i, dp[i].size());
        for (long long j = 0; j < std::min((int) dp[i].size(), 1000000); ++j) {
            if (j > 0 && dp[i][j] >> 32 == dp[i][j - 1] >> 32) {
                continue;
            }
            long long a = dp[i][j] >> 58 & 0x3F;
            long long b = dp[i][j] >> 45 & 0x1FFF;
            long long c = dp[i][j] >> 32 & 0x1FFF;
            // long long jj = dp[i][j] >> 2 & 0x3FFFFFFF;
            if (c == K || c + b == K || c + b + b <= K || c + b + a <= K) {
                long long rem = N - i;
                long long best = st[rem][a][b];
                if (best < 0) {
                    // best = b * rem + a * (rem / 2) * ((rem + 1) / 2) + (rem /
                    // 3) * ((rem + 1) / 3) * ((rem + 2) / 3);
                    for (long long z = 0; z <= rem; ++z) {
                        long long tot = rem - z;
                        long long axy = 0;
                        if (tot <= a) {
                            axy = a * tot;
                        } else {
                            axy = ((a + tot) / 2) * ((a + tot + 1) / 2);
                        }
                        best = std::max(best, (axy + b) * z);
                    }
                    st[rem][a][b] = best;
                }
                if (c + best >= K) {
                    if (str[i] == 'N') {
                        dp[i + 1].push_back(a + 1 << 58 | b << 45 | c << 32 |
                                            j << 2 | 0);
                    } else if (str[i] == 'A') {
                        dp[i + 1].push_back(a << 58 | b + a << 45 | c << 32 |
                                            j << 2 | 0);
                    } else if (str[i] == 'C') {
                        dp[i + 1].push_back(a << 58 | b << 45 | c + b << 32 |
                                            j << 2 | 0);
                    } else if (str[i] == '?') {
                        if (a + 1 + b + c <= K)
                            dp[i + 1].push_back(a + 1 << 58 | b << 45 |
                                                c << 32 | j << 2 | 1);
                        if (a > 0 && b + a + c <= K)
                            dp[i + 1].push_back(a << 58 | b + a << 45 |
                                                c << 32 | j << 2 | 2);
                        if (b > 0 && c + b <= K)
                            dp[i + 1].push_back(a << 58 | b << 45 |
                                                c + b << 32 | j << 2 | 3);
                        dp[i + 1].push_back(a << 58 | b << 45 | c << 32 |
                                            j << 2 | 0);
                    } else {
                        dp[i + 1].push_back(a << 58 | b << 45 | c << 32 |
                                            j << 2 | 0);
                    }
                }
            }
        }
    }
    for (long long f = 0; f < dp[N].size(); ++f) {
        long long c = dp[N][f] >> 32 & 0x1FFF;
        if (c == K) {
            std::string ans;
            // printf("%d %lld %d\n", f, c, K);
            for (int i = N; i > 0; --i) {
                ans.push_back(dp[i][f] & 3
                                  ? "?NAC"[dp[i][f] & 3]
                                  : (str[i - 1] == '?' ? 'B' : str[i - 1]));
                f = dp[i][f] >> 2 & 0x3FFFFFF;
                // printf("%d %d %d %lld %d\n", i, (int)dp[i].size(), f, c, K);
            }
            std::reverse(ans.begin(), ans.end());
            printf("%s\n", ans.c_str());
            return 0;
        }
    }
    puts("-1");
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

22 2
N??A??????C???????????

output:

NBBABBBBBBCBBBBBBBBBBC

result:

ok correct

Test #2:

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

input:

18 0
COUNTINGSATELLITES

output:

COUNTINGSATELLITES

result:

ok correct

Test #3:

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

input:

2 1
??

output:

-1

result:

ok correct

Test #4:

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

input:

1 0
?

output:

B

result:

ok correct

Test #5:

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

input:

1 0
N

output:

N

result:

ok correct

Test #6:

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

input:

1 0
X

output:

X

result:

ok correct

Test #7:

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

input:

1 1
?

output:

-1

result:

ok correct

Test #8:

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

input:

1 1
N

output:

-1

result:

ok correct

Test #9:

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

input:

1 1
X

output:

-1

result:

ok correct

Test #10:

score: 0
Accepted
time: 5ms
memory: 52596kb

input:

2 0
??

output:

BB

result:

ok correct

Test #11:

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

input:

2 0
N?

output:

NB

result:

ok correct

Test #12:

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

input:

2 0
?C

output:

BC

result:

ok correct

Test #13:

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

input:

2 1
N?

output:

-1

result:

ok correct

Test #14:

score: 0
Accepted
time: 5ms
memory: 52408kb

input:

2 1
?C

output:

-1

result:

ok correct

Test #15:

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

input:

3 1
???

output:

NAC

result:

ok correct

Test #16:

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

input:

3 1
N??

output:

NAC

result:

ok correct

Test #17:

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

input:

3 1
?A?

output:

NAC

result:

ok correct

Test #18:

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

input:

3 1
??C

output:

NAC

result:

ok correct

Test #19:

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

input:

3 1
NA?

output:

NAC

result:

ok correct

Test #20:

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

input:

3 1
N?C

output:

NAC

result:

ok correct

Test #21:

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

input:

3 1
?AC

output:

NAC

result:

ok correct

Test #22:

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

input:

4 1
????

output:

BNAC

result:

ok correct

Test #23:

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

input:

4 1
X???

output:

XNAC

result:

ok correct

Test #24:

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

input:

4 1
???Z

output:

NACZ

result:

ok correct

Test #25:

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

input:

4 1
?AA?

output:

-1

result:

ok correct

Test #26:

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

input:

4 1
N???

output:

NBAC

result:

ok correct

Test #27:

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

input:

4 1
?N??

output:

BNAC

result:

ok correct

Test #28:

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

input:

4 1
??N?

output:

NANC

result:

ok correct

Test #29:

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

input:

4 1
???N

output:

NACN

result:

ok correct

Test #30:

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

input:

4 1
A???

output:

ANAC

result:

ok correct

Test #31:

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

input:

4 1
?A??

output:

NABC

result:

ok correct

Test #32:

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

input:

4 1
??A?

output:

BNAC

result:

ok correct

Test #33:

score: 0
Accepted
time: 5ms
memory: 52580kb

input:

4 1
???A

output:

NACA

result:

ok correct

Test #34:

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

input:

4 1
C???

output:

CNAC

result:

ok correct

Test #35:

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

input:

4 1
?C??

output:

NCAC

result:

ok correct

Test #36:

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

input:

4 1
??C?

output:

NACB

result:

ok correct

Test #37:

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

input:

4 1
???C

output:

BNAC

result:

ok correct

Test #38:

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

input:

5 4
?????

output:

NAACC

result:

ok correct

Test #39:

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

input:

6 14
??????

output:

-1

result:

ok correct

Test #40:

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

input:

7 14
???????

output:

-1

result:

ok correct

Test #41:

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

input:

8 43
????????

output:

-1

result:

ok correct

Test #42:

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

input:

9 55
?????????

output:

-1

result:

ok correct

Test #43:

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

input:

10 112
??????????

output:

-1

result:

ok correct

Test #44:

score: 0
Accepted
time: 5ms
memory: 52448kb

input:

11 110
???????????

output:

-1

result:

ok correct

Test #45:

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

input:

12 4
????????????

output:

BBBBBBNACCCC

result:

ok correct

Test #46:

score: 0
Accepted
time: 5ms
memory: 52512kb

input:

13 193
?????????????

output:

-1

result:

ok correct

Test #47:

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

input:

14 91
??????????????

output:

NNNANAAACACCCC

result:

ok correct

Test #48:

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

input:

15 15
???????????????

output:

BBBBBBNAAACCCCC

result:

ok correct

Test #49:

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

input:

16 261
????????????????

output:

-1

result:

ok correct

Test #50:

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

input:

17 514
?????????????????

output:

-1

result:

ok correct

Test #51:

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

input:

18 678
??????????????????

output:

-1

result:

ok correct

Test #52:

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

input:

19 40
???????????????????

output:

BBBBBBBNNAACACCCCCC

result:

ok correct

Test #53:

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

input:

20 1019
????????????????????

output:

-1

result:

ok correct

Test #54:

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

input:

21 1218
?????????????????????

output:

-1

result:

ok correct

Test #55:

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

input:

22 1348
??????????????????????

output:

-1

result:

ok correct

Test #56:

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

input:

23 476
???????????????????????

output:

-1

result:

ok correct

Test #57:

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

input:

24 1445
????????????????????????

output:

-1

result:

ok correct

Test #58:

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

input:

25 1331
?????????????????????????

output:

-1

result:

ok correct

Test #59:

score: 0
Accepted
time: 14ms
memory: 53028kb

input:

26 459
??????????????????????????

output:

BNNNNANAAAAAAACCCCCACCCCCC

result:

ok correct

Test #60:

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

input:

27 398
???????????????????????????

output:

BBBNNNNANAAAAACCACCCCCCCCCC

result:

ok correct

Test #61:

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

input:

28 274
????????????????????????????

output:

BBBBBBBNNNNAAAANAACACCCCCCCC

result:

ok correct

Test #62:

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

input:

29 1624
?????????????????????????????

output:

-1

result:

ok correct

Test #63:

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

input:

30 2079
??????????????????????????????

output:

-1

result:

ok correct

Test #64:

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

input:

31 2067
???????????????????????????????

output:

-1

result:

ok correct

Test #65:

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

input:

32 1267
????????????????????????????????

output:

-1

result:

ok correct

Test #66:

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

input:

33 928
?????????????????????????????????

output:

BBNNNNNNAAAANAAAAAACCCACCCCCCCCCC

result:

ok correct

Test #67:

score: 0
Accepted
time: 9ms
memory: 52752kb

input:

34 298
??????????????????????????????????

output:

BBBBBBBBBBBBNNNANAAAAAACCCACCCCCCC

result:

ok correct

Test #68:

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

input:

35 2361
???????????????????????????????????

output:

-1

result:

ok correct

Test #69:

score: 0
Accepted
time: 8ms
memory: 52968kb

input:

36 489
????????????????????????????????????

output:

BBBBBBBBBBBNNNNNAAANAAAACACCCCCCCCCC

result:

ok correct

Test #70:

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

input:

37 294
?????????????????????????????????????

output:

BBBBBBBBBBBBBBBBNNNNAANAAAAACCACCCCCC

result:

ok correct

Test #71:

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

input:

38 1558
??????????????????????????????????????

output:

BBNNNNNNNNAANAAAAAAAAAAACCCCCCACCCCCCC

result:

ok correct

Test #72:

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

input:

39 1319
???????????????????????????????????????

output:

BBBBBNNNNNNNNANAAAAAAAAAACCCCCCCCACCCCC

result:

ok correct

Test #73:

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

input:

40 993
????????????????????????????????????????

output:

BBBBBBBBBNNNNNNNAAANAAAAAACACCCCCCCCCCCC

result:

ok correct

Test #74:

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

input:

40 498
ACNANACNNACNACNNNCNCNNNANNNACNCCACAA?ANA

output:

-1

result:

ok correct

Test #75:

score: 0
Accepted
time: 5ms
memory: 52472kb

input:

40 855
NAAANAACNNNCNAANCNANCNANACANCCAANCACNCAC

output:

-1

result:

ok correct

Test #76:

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

input:

40 1007
?CNACNNAANACANACNACCC?CAANNCCCCANNANCACN

output:

-1

result:

ok correct

Test #77:

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

input:

40 1778
NACANANN?CCANNCCAACNNCCNCCCNCCNACCNC?NNN

output:

-1

result:

ok correct

Test #78:

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

input:

40 2186
ACCCACAN?NNA?AACCNNNN?ANACCANCNCNNCA?NCN

output:

-1

result:

ok correct

Test #79:

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

input:

40 332
ACAC?NCCCANAA?ACCNNC?NAC?CAC?CNCNNACNNNN

output:

-1

result:

ok correct

Test #80:

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

input:

40 712
ANCNANAAC?CACAACA?CNACCCANAACCA?CNNAANCN

output:

-1

result:

ok correct

Test #81:

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

input:

40 1127
C?CAAAANNCANANAC?NCANACANAACAACANNCCNCAC

output:

-1

result:

ok correct

Test #82:

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

input:

40 1835
CANNCAANNNAANANNCACANAC?CCCCAACA?NNNCAC?

output:

-1

result:

ok correct

Test #83:

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

input:

40 2009
CANAAAN?ANAACNCCNCCNCAAANCANCCAN?CCNCAAN

output:

-1

result:

ok correct

Test #84:

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

input:

40 54
CNAC?ACAAC?ACC?ANC?C?NNCAANCCAC?NCN?CACA

output:

-1

result:

ok correct

Test #85:

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

input:

40 955
?A?ANA?NN?C?ANC??CNNACAAC?N?AAN?AN??ANNA

output:

-1

result:

ok correct

Test #86:

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

input:

40 1451
??CCCA?N?ACCN?C???NNN??C?ANAN??NCNA??NAN

output:

-1

result:

ok correct

Test #87:

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

input:

40 1526
CN??AC?CCCCNACCNCNCCNC?CAAN?C?CA??ANCN?A

output:

-1

result:

ok correct

Test #88:

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

input:

40 2453
C?NC?CCAAN?ACCCNCC??ACAANCANCNCNNAACC?NN

output:

-1

result:

ok correct

Test #89:

score: 0
Accepted
time: 8ms
memory: 53908kb

input:

40 166
?NC??AACAN??NCA?CCAA?A??CNNN?ACNN?AN?ANC

output:

BNCBBAACANBCNCACCCAABACCCNNNCACNNCANBANC

result:

ok correct

Test #90:

score: 0
Accepted
time: 70ms
memory: 72048kb

input:

40 887
?NA?AN?N?A?ANN??N?ANCAN?N????AC?NN?NA???

output:

NNANANANAAAANNCANAANCANCNCACCACCNNCNACCC

result:

ok correct

Test #91:

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

input:

40 1310
CCN?NNANC??CANN??NC?N??NA?NNNNCN?N?CCCCC

output:

-1

result:

ok correct

Test #92:

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

input:

40 1568
ANCN?N?NACC??NNN?AAC?AANA?CA?NC?CNNAN??N

output:

-1

result:

ok correct

Test #93:

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

input:

40 2035
CA?N?ACCNN??CANA?NC?NACNC??CC???NCA?N?AC

output:

-1

result:

ok correct

Test #94:

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

input:

40 126
AC?CACCCN???C?NCCN?NN??CN?CNCN?C?N?C?A?C

output:

ACBCACCCNACACANCCNBNNCACNCCNCNCCCNCCCACC

result:

ok correct

Test #95:

score: 0
Accepted
time: 15ms
memory: 56316kb

input:

40 962
CCC???A??????AN?N???C?NN??CANA?CNA??N???

output:

CCCNNNANNANANANANAAACCNNAACANACCNACCNCCC

result:

ok correct

Test #96:

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

input:

40 1043
?A??NANA?CN?N?AN?ANN?CNAANCC??AAANNN????

output:

-1

result:

ok correct

Test #97:

score: 0
Accepted
time: 5ms
memory: 52508kb

input:

40 1638
N?ANA?NA???A??N?CNNAA???NC????CNN??AC??N

output:

-1

result:

ok correct

Test #98:

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

input:

40 2240
NNC??NCA???N?N?NNC??CNNNAN??C?AN??AC?C??

output:

-1

result:

ok correct

Test #99:

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

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: 302ms
memory: 128008kb

input:

40 639
C???NN??C?N?N????N?CA?NCAN????AN????NA??

output:

CBBNNNAACANANAACCNACACNCANCCCCANCCCCNACC

result:

ok correct

Test #101:

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

input:

40 1438
?C?A?NA?AN???CA???NAAAN??A?NNANNCAA?????

output:

-1

result:

ok correct

Test #102:

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

input:

40 1660
???C?A???????NN??AANNAC???A?CN??ACN?AC?C

output:

-1

result:

ok correct

Test #103:

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

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: 91ms
memory: 78588kb

input:

40 242
?C???A???AA??A??C?CN???C???A?ANA?NN??AA?

output:

BCBBNANACAACCACCCACNCCCCCCCACANACNNCCAAC

result:

ok correct

Test #105:

score: 0
Accepted
time: 346ms
memory: 139524kb

input:

40 711
??A?AA?C??C???CCNA?????C????A?????A??C??

output:

NNANAAACAACACACCNACCCCCCCCACACCCCCACCCCC

result:

ok correct

Test #106:

score: 0
Accepted
time: 170ms
memory: 96388kb

input:

40 1094
??AACN??N?A?????C????AA??CC???CC?N?A????

output:

NNAACNANNAAAAAAACACCAAACCCCCCCCCCNCACCCC

result:

ok correct

Test #107:

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

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: 0ms
memory: 52480kb

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: 174ms
memory: 98668kb

input:

40 268
N?N??NNNCNC??CAC????A?C?????N???AN??NC??

output:

NBNBBNNNCNCBBCACCCCCACCCCACCNCCCANBCNCCC

result:

ok correct

Test #110:

score: 0
Accepted
time: 497ms
memory: 175112kb

input:

40 960
?????????N???NA?????????C??AC???AN?A???A

output:

NNAANAAAANAAANAAAAAAACCCCCCACCCCANCACCCA

result:

ok correct

Test #111:

score: 0
Accepted
time: 76ms
memory: 73148kb

input:

40 1342
???C?????C?????NA?N??N?C?????A?N???NA???

output:

NNNCNNNNNCNAAANNAANAANACAACCCACNCCCNACCC

result:

ok correct

Test #112:

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

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: 0ms
memory: 52516kb

input:

40 2484
??????N????N?????N?C??N????????????A???N

output:

-1

result:

ok correct

Test #114:

score: 0
Accepted
time: 14ms
memory: 52948kb

input:

40 116
?CN????????A??A???C????????????????C????

output:

BCNBBBBBBBBABBABBBCBBBBNAAACCCACCCCCCCCC

result:

ok correct

Test #115:

score: 0
Accepted
time: 294ms
memory: 127528kb

input:

40 538
NC???N?????????????NN??N????????CC???N??

output:

NCBBBNBBAAAAAAAACCANNAANAAAACCCCCCCCCNCC

result:

ok correct

Test #116:

score: 0
Accepted
time: 568ms
memory: 171180kb

input:

40 1128
?????AN?????CN????N?A????C???C??????????

output:

NNNAAANAAAAACNACACNAAACCCCCCCCCCCCCCCCCC

result:

ok correct

Test #117:

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

input:

40 1819
?????????C?AC?????C??A??NC?????????????C

output:

-1

result:

ok correct

Test #118:

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

input:

40 2198
??????A???N????????ANN???N?C??????C?????

output:

-1

result:

ok correct

Test #119:

score: 0
Accepted
time: 45ms
memory: 62920kb

input:

40 373
???????????C?A?????????A???A?C??????????

output:

BBBBBBBBBBBCBANNANAAAAAAAAAACCCCACCCCCCC

result:

ok correct

Test #120:

score: 0
Accepted
time: 234ms
memory: 108848kb

input:

40 744
?????????????????C????????????A????C???N

output:

BBBBBBBNNNNANAAAACAAAACCCCCCCCACCACCCCCN

result:

ok correct

Test #121:

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

input:

40 1103
???????????????????????????N????????????

output:

BBBBBBNNNNNNAAANAAAAAAACACCNCCCCCCCCCCCC

result:

ok correct

Test #122:

score: 0
Accepted
time: 122ms
memory: 85208kb

input:

40 1866
???????A??????A??A???????????????C??????

output:

NNNNNNNAANAAAAAAAAAACCCCCCCCCACCCCCCCCCC

result:

ok correct

Test #123:

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

input:

40 2466
????????????CN?????????????????N??CA????

output:

-1

result:

ok correct

Test #124:

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

input:

40 1
?????????????????????????????????????NAC

output:

BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBNAC

result:

ok correct