QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#184668#5562. Jesting JabberwockyrgnerdplayerAC ✓92ms9232kbC++201.2kb2023-09-21 02:58:532023-09-21 02:58:54

Judging History

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

  • [2023-09-21 02:58:54]
  • 评测
  • 测评结果:AC
  • 用时:92ms
  • 内存:9232kb
  • [2023-09-21 02:58:53]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using i64 = long long;

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    auto solve = [&]() {
        string s;
        cin >> s;

        int n = s.size();

        string suit = "cdhs";

        int ans = n;

        do {
            vector<int> a(n);
            for (int i = 0; i < n; i++) {
                a[i] = suit.find(s[i]);
            }

            // for (int i = 0; i < n; i++) {
            //     cout << a[i] << " \n"[i == n - 1];
            // }

            vector dp(n + 1, vector<int>(4));

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < 4; j++) {
                    dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + (a[i] == j));
                    if (j < 3) {
                        dp[i + 1][j + 1] = dp[i + 1][j];
                    }
                }
            }

            // cout << dp[n][3] << '\n';

            ans = min(ans, n - dp[n][3]);
        } while (next_permutation(suit.begin(), suit.end()));

        cout << ans << '\n';
    };
    
    solve();
    
    return 0;
}

详细

Test #1:

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

input:

hccdhcd

output:

2

result:

ok single line: '2'

Test #2:

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

input:

cchhdshcdshdcsh

output:

7

result:

ok single line: '7'

Test #3:

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

input:

c

output:

0

result:

ok single line: '0'

Test #4:

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

input:

cchhhddss

output:

0

result:

ok single line: '0'

Test #5:

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

input:

chchchch

output:

3

result:

ok single line: '3'

Test #6:

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

input:

cccchhccddcccccsscccc

output:

6

result:

ok single line: '6'

Test #7:

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

input:

shhssdsddsddcddhchss

output:

8

result:

ok single line: '8'

Test #8:

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

input:

cshhscshdscscchssshs

output:

9

result:

ok single line: '9'

Test #9:

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

input:

hchdschhdhchhdcssccs

output:

8

result:

ok single line: '8'

Test #10:

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

input:

chchcsdcchdhdcsdssdh

output:

9

result:

ok single line: '9'

Test #11:

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

input:

shhdhchcdhcssdcssdss

output:

8

result:

ok single line: '8'

Test #12:

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

input:

ddcdsdsddhshdshhchdh

output:

8

result:

ok single line: '8'

Test #13:

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

input:

sdhsccsshchsshsshshs

output:

8

result:

ok single line: '8'

Test #14:

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

input:

cdddccdssdhhhshdcchh

output:

7

result:

ok single line: '7'

Test #15:

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

input:

ddcddhdshdhdcdcshcss

output:

8

result:

ok single line: '8'

Test #16:

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

input:

csddhhshhddsdccdcsds

output:

8

result:

ok single line: '8'

Test #17:

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

input:

hdcshcscdhddhhdshchc

output:

10

result:

ok single line: '10'

Test #18:

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

input:

hchshdcdshddshshshdc

output:

9

result:

ok single line: '9'

Test #19:

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

input:

ccddhsddccdshdcddddd

output:

7

result:

ok single line: '7'

Test #20:

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

input:

ssdssccdhdsdsdccshcc

output:

8

result:

ok single line: '8'

Test #21:

score: 0
Accepted
time: 67ms
memory: 8596kb

input:

schhchsshscsdschhshddsdhchchshddhddchchdsdchcddddshcscsdhscsddchdcscshdsdddhsdhdchcdcdcsdhhshcsccdchhschshhsdschhhcdchsshdcdhschhdchcddcccchdhcchshhcshdshdssdddhcchdccddhcsshhcdddcdhcchdhddchdshshcscdsdcchchdhcshhscsdchhsdcdhdshdcsdhhhdcddcscdddssccdddccscsdcscchdcsdccdscdshhccchdsscdhhsccsssdcdcsdc...

output:

67475

result:

ok single line: '67475'

Test #22:

score: 0
Accepted
time: 66ms
memory: 8280kb

input:

hsccchcdssddsschddchdcdhdhshccchddcshdcsdcdcccshscccchhhdccshhhsdhcchddhdshssdsccdshdshdcccccchsdhhsdhdscdccdscddcccsssdddshsdhcdcsshhdsshssshdhhhsdcshcccdcsscdhdddhsdsshhddchsdhsssdscddcsccsshccccccshhchdhhhchcccsddchhdhhcschssdccshdscdhhhdsdshdhssdsshdhddcchhhhddchhsssdsdchshscccschcdchchhdcdhscdh...

output:

62915

result:

ok single line: '62915'

Test #23:

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

input:

hshhcsshsdsdchsshdssdchdcsdshccdsshdchsshhcssshcshshhcddhshsdhdcsdhchshdhchhsschhscdhccdcschcsdhddddchchddhhscssccdhhhhhcdchhhhshhdchchcchcshdhdhcddcdhschddsssdcsdhhdsccddcdhcccsshdshshcchschddchshshsdhdhcsdchdchdsssscdschccssdhschcccssddsshhdchhsscdsshcdssdssscsscdhchcsdcchscdsdhhsdshhhccddhsshhdds...

output:

24067

result:

ok single line: '24067'

Test #24:

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

input:

sssdsdchhshdcsccdhdsddsdshchhschdhsschhsshchdcsscdchsshschhsscdshschcddshdsdddshcdhhsscsdchcshddchsdschhdhhdscscsdsdhcdsccdhhshhchshshccccshdcdddddddshsdchchcsddhcchchhsdhcddcsshcsshdhdhscsdhsdshhcdddcshsdhshhssddcdchdsdhcdshsschdschdhdccdhshcdhhhhddcchddchsdhhsccddsdcsscdhhsdscshccssschdsdchccdcdhh...

output:

638

result:

ok single line: '638'

Test #25:

score: 0
Accepted
time: 72ms
memory: 9232kb

input:

hdhccsdhdddcddcdccddddsssdccchshhcchshhschcdsdcdssscshdsschdhshdsdhsschccshscchcddcdhdchsdccdsshdsdchddsccddcsddhcsdchdccsccddshhdchsdddscsdhcccshhdscscshsssscdcschdhscssddscshcddccchsddcchcdhsscdchdhdchsccschcdsdscdhddcdssdddhhsdsdccdshshdschdhhhscshssccdhsddhsdhshchhhhcschdssdddhcdddhdshhcdhhsschd...

output:

74459

result:

ok single line: '74459'

Test #26:

score: 0
Accepted
time: 81ms
memory: 9108kb

input:

dhdssscccshcdhhcsdhhdcschhshcchdcsddshshchhhchddhsshcdddsssdsshscscshdsdccshdscschsdscdhhshhdhhhhdhshhdhsdhhccchccchhhcschshdcddhssdsdsddccdsshdchcsdhhdcsdddcshhcdhchcscsdhchhhcdsdddsdccdddhdhddsscsddsddschshdssccchcshhscshddhdhdsddcdddsscdcsdhsdddhscdsshcscdcdhdssdhdscdchcsdhscshcdsshcdchcsdhsdhddd...

output:

74427

result:

ok single line: '74427'

Test #27:

score: 0
Accepted
time: 82ms
memory: 9160kb

input:

hcdchhsdcshhhhcsscsdsdcshchdhhdcchccdchsdsddchcdchdcssshhcdhchsdccsschshcssshdshcdchdshhhcchscshccsshdddcshsccddsshchhsddshccsshsddcdscccddhcsddssccdchsshccshsdsscsdcdssdhhddcccchhsssdhscdhshccsshddcsdshcdddshdshhddchdscscdhhhhddcsddchhcccdshcdcccddscscdsccchhccdddcscscdhsdhhhchcccdccddsdhhchhchdcsh...

output:

74431

result:

ok single line: '74431'

Test #28:

score: 0
Accepted
time: 48ms
memory: 9168kb

input:

cdcdshhhhdsshdsdchhccdcsshsdsshdhshdshhddsdshdchsccsccdhcdshsdscdcdcsshhsdchsscdsshcshssdddshcdsscchhddhchsdsshccdhchdhhhcchdhccscshcchcchddhccscdhsdhsshsssddddcchdchssddhchsdhhdsccsdsdhchchhcchdchhscddcsdcdsddcddchdcshchschdhdhchddccchchcshccsdcccdcdcdhsddddchchshchdhsshhdhccsdhhcdscsscsshchcdhcdhc...

output:

74497

result:

ok single line: '74497'

Test #29:

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

input:

dcshshcdschdschdhscdcdshhdcsdhcsshdcshdcchsddhcshcsdsdchdchshcsdscdhhdsccsdhhdcsshdchscddshcsdchsdhc

output:

72

result:

ok single line: '72'

Test #30:

score: 0
Accepted
time: 64ms
memory: 9168kb

input:

chdsdhcscdhscdhsdcshsdchshdcdhcssdchhcdsdchsdchsschdhcsdchsddschcshdcsdhhcsddchssdhcchsdscdhschdchdsdchsdshcshcdcshdscdhhsdchcsdhdschdscshcddschhcdsdschhscddshcshdcshcdschdhcsdcdshshdchdschdcsdchscshddcshscdhcdshdshcchsdshdchcsddcshschddschcdshdshcdshcsdhcchdsdschsdchhdscchsddschdhsccdshhsdcdschhdcs...

output:

74997

result:

ok single line: '74997'

Test #31:

score: 0
Accepted
time: 67ms
memory: 9068kb

input:

cccccccccccscccccccccccccccccccccccccccsccccccccccccccccccccccccccccccccccccccccccccccsccccccccccccccccsccccccccccccccsccccccsccccsccchcsccsccccccccsccccccccccccccccsccccccscccccssscccccccccccccccscccccccccsccccccscccccccccsccsccccccccccccccccsccscchccccscccccccsccscccccccscccccccccccsccsccccccscccc...

output:

57178

result:

ok single line: '57178'

Test #32:

score: 0
Accepted
time: 92ms
memory: 9084kb

input:

cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccchhcccccchcccccccccccccccccccchccccccccccccccchccccccccccccccccccccccchccccccccccccccccccccccchcccccccchccccccccccccccccccccccccccccccccchcccchcccccccccccccccccccccccccchcccccccccccchccccccchcccccccccccc...

output:

35623

result:

ok single line: '35623'

Test #33:

score: 0
Accepted
time: 69ms
memory: 9168kb

input:

cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc...

output:

23657

result:

ok single line: '23657'

Test #34:

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

input:

dddcdddddddddddddddcdddddddddddddddddhddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddsddddddddddddddddddddddddd...

output:

69

result:

ok single line: '69'

Test #35:

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

input:

cccccccccchccccccccccccccccccccccccccccccccccccchhshhhhhhhhshhhhhhhhdhhhhhhhhhhhhhhhhhhhhhhhhhhhhhdddddddddddddddddddddddddddddddddddcddddddddddddddssssssssshssscssssssssscssssshssssssssssssssssssssss

output:

9

result:

ok single line: '9'

Test #36:

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

input:

cchhdhssdcddchccddhsdsshcdhhdhdccshcssss

output:

21

result:

ok single line: '21'