QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#85160#5562. Jesting JabberwockytaniyaAC ✓16ms6912kbC++23479b2023-03-07 02:00:432023-03-07 02:00:46

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-07 02:00:46]
  • 评测
  • 测评结果:AC
  • 用时:16ms
  • 内存:6912kb
  • [2023-03-07 02:00:43]
  • 提交

answer

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char s[200001],p[5]="hdcs";
long long length,answer,i,j,k,f[5][200001];
int main ()
{
	scanf("%s",s);
	length=strlen(s);
	answer=length;
	for (i=0;i<24;i++)
	{
		for (j=1;j<=4;j++)
		for (k=1;k<=length;k++)
		f[j][k]=max(f[j-1][k-1],f[j][k-1])+(s[k-1]==p[j-1]);
		answer=min(length-f[4][length],answer);
		next_permutation(p,p+4);
	}
	printf("%lld",answer);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3544kb

input:

hccdhcd

output:

2

result:

ok single line: '2'

Test #2:

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

input:

cchhdshcdshdcsh

output:

7

result:

ok single line: '7'

Test #3:

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

input:

c

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 2ms
memory: 3836kb

input:

cchhhddss

output:

0

result:

ok single line: '0'

Test #5:

score: 0
Accepted
time: 2ms
memory: 3836kb

input:

chchchch

output:

3

result:

ok single line: '3'

Test #6:

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

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: 2ms
memory: 3604kb

input:

cshhscshdscscchssshs

output:

9

result:

ok single line: '9'

Test #9:

score: 0
Accepted
time: 2ms
memory: 3684kb

input:

hchdschhdhchhdcssccs

output:

8

result:

ok single line: '8'

Test #10:

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

input:

chchcsdcchdhdcsdssdh

output:

9

result:

ok single line: '9'

Test #11:

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

input:

shhdhchcdhcssdcssdss

output:

8

result:

ok single line: '8'

Test #12:

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

input:

ddcdsdsddhshdshhchdh

output:

8

result:

ok single line: '8'

Test #13:

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

input:

sdhsccsshchsshsshshs

output:

8

result:

ok single line: '8'

Test #14:

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

input:

cdddccdssdhhhshdcchh

output:

7

result:

ok single line: '7'

Test #15:

score: 0
Accepted
time: 2ms
memory: 3816kb

input:

ddcddhdshdhdcdcshcss

output:

8

result:

ok single line: '8'

Test #16:

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

input:

csddhhshhddsdccdcsds

output:

8

result:

ok single line: '8'

Test #17:

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

input:

hdcshcscdhddhhdshchc

output:

10

result:

ok single line: '10'

Test #18:

score: 0
Accepted
time: 2ms
memory: 3844kb

input:

hchshdcdshddshshshdc

output:

9

result:

ok single line: '9'

Test #19:

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

input:

ccddhsddccdshdcddddd

output:

7

result:

ok single line: '7'

Test #20:

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

input:

ssdssccdhdsdsdccshcc

output:

8

result:

ok single line: '8'

Test #21:

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

input:

schhchsshscsdschhshddsdhchchshddhddchchdsdchcddddshcscsdhscsddchdcscshdsdddhsdhdchcdcdcsdhhshcsccdchhschshhsdschhhcdchsshdcdhschhdchcddcccchdhcchshhcshdshdssdddhcchdccddhcsshhcdddcdhcchdhddchdshshcscdsdcchchdhcshhscsdchhsdcdhdshdcsdhhhdcddcscdddssccdddccscsdcscchdcsdccdscdshhccchdsscdhhsccsssdcdcsdc...

output:

67475

result:

ok single line: '67475'

Test #22:

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

input:

hsccchcdssddsschddchdcdhdhshccchddcshdcsdcdcccshscccchhhdccshhhsdhcchddhdshssdsccdshdshdcccccchsdhhsdhdscdccdscddcccsssdddshsdhcdcsshhdsshssshdhhhsdcshcccdcsscdhdddhsdsshhddchsdhsssdscddcsccsshccccccshhchdhhhchcccsddchhdhhcschssdccshdscdhhhdsdshdhssdsshdhddcchhhhddchhsssdsdchshscccschcdchchhdcdhscdh...

output:

62915

result:

ok single line: '62915'

Test #23:

score: 0
Accepted
time: 2ms
memory: 4712kb

input:

hshhcsshsdsdchsshdssdchdcsdshccdsshdchsshhcssshcshshhcddhshsdhdcsdhchshdhchhsschhscdhccdcschcsdhddddchchddhhscssccdhhhhhcdchhhhshhdchchcchcshdhdhcddcdhschddsssdcsdhhdsccddcdhcccsshdshshcchschddchshshsdhdhcsdchdchdsssscdschccssdhschcccssddsshhdchhsscdsshcdssdssscsscdhchcsdcchscdsdhhsdshhhccddhsshhdds...

output:

24067

result:

ok single line: '24067'

Test #24:

score: 0
Accepted
time: 2ms
memory: 3696kb

input:

sssdsdchhshdcsccdhdsddsdshchhschdhsschhsshchdcsscdchsshschhsscdshschcddshdsdddshcdhhsscsdchcshddchsdschhdhhdscscsdsdhcdsccdhhshhchshshccccshdcdddddddshsdchchcsddhcchchhsdhcddcsshcsshdhdhscsdhsdshhcdddcshsdhshhssddcdchdsdhcdshsschdschdhdccdhshcdhhhhddcchddchsdhhsccddsdcsscdhhsdscshccssschdsdchccdcdhh...

output:

638

result:

ok single line: '638'

Test #25:

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

input:

hdhccsdhdddcddcdccddddsssdccchshhcchshhschcdsdcdssscshdsschdhshdsdhsschccshscchcddcdhdchsdccdsshdsdchddsccddcsddhcsdchdccsccddshhdchsdddscsdhcccshhdscscshsssscdcschdhscssddscshcddccchsddcchcdhsscdchdhdchsccschcdsdscdhddcdssdddhhsdsdccdshshdschdhhhscshssccdhsddhsdhshchhhhcschdssdddhcdddhdshhcdhhsschd...

output:

74459

result:

ok single line: '74459'

Test #26:

score: 0
Accepted
time: 16ms
memory: 6768kb

input:

dhdssscccshcdhhcsdhhdcschhshcchdcsddshshchhhchddhsshcdddsssdsshscscshdsdccshdscschsdscdhhshhdhhhhdhshhdhsdhhccchccchhhcschshdcddhssdsdsddccdsshdchcsdhhdcsdddcshhcdhchcscsdhchhhcdsdddsdccdddhdhddsscsddsddschshdssccchcshhscshddhdhdsddcdddsscdcsdhsdddhscdsshcscdcdhdssdhdscdchcsdhscshcdsshcdchcsdhsdhddd...

output:

74427

result:

ok single line: '74427'

Test #27:

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

input:

hcdchhsdcshhhhcsscsdsdcshchdhhdcchccdchsdsddchcdchdcssshhcdhchsdccsschshcssshdshcdchdshhhcchscshccsshdddcshsccddsshchhsddshccsshsddcdscccddhcsddssccdchsshccshsdsscsdcdssdhhddcccchhsssdhscdhshccsshddcsdshcdddshdshhddchdscscdhhhhddcsddchhcccdshcdcccddscscdsccchhccdddcscscdhsdhhhchcccdccddsdhhchhchdcsh...

output:

74431

result:

ok single line: '74431'

Test #28:

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

input:

cdcdshhhhdsshdsdchhccdcsshsdsshdhshdshhddsdshdchsccsccdhcdshsdscdcdcsshhsdchsscdsshcshssdddshcdsscchhddhchsdsshccdhchdhhhcchdhccscshcchcchddhccscdhsdhsshsssddddcchdchssddhchsdhhdsccsdsdhchchhcchdchhscddcsdcdsddcddchdcshchschdhdhchddccchchcshccsdcccdcdcdhsddddchchshchdhsshhdhccsdhhcdscsscsshchcdhcdhc...

output:

74497

result:

ok single line: '74497'

Test #29:

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

input:

dcshshcdschdschdhscdcdshhdcsdhcsshdcshdcchsddhcshcsdsdchdchshcsdscdhhdsccsdhhdcsshdchscddshcsdchsdhc

output:

72

result:

ok single line: '72'

Test #30:

score: 0
Accepted
time: 6ms
memory: 6852kb

input:

chdsdhcscdhscdhsdcshsdchshdcdhcssdchhcdsdchsdchsschdhcsdchsddschcshdcsdhhcsddchssdhcchsdscdhschdchdsdchsdshcshcdcshdscdhhsdchcsdhdschdscshcddschhcdsdschhscddshcshdcshcdschdhcsdcdshshdchdschdcsdchscshddcshscdhcdshdshcchsdshdchcsddcshschddschcdshdshcdshcsdhcchdsdschsdchhdscchsddschdhsccdshhsdcdschhdcs...

output:

74997

result:

ok single line: '74997'

Test #31:

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

input:

cccccccccccscccccccccccccccccccccccccccsccccccccccccccccccccccccccccccccccccccccccccccsccccccccccccccccsccccccccccccccsccccccsccccsccchcsccsccccccccsccccccccccccccccsccccccscccccssscccccccccccccccscccccccccsccccccscccccccccsccsccccccccccccccccsccscchccccscccccccsccscccccccscccccccccccsccsccccccscccc...

output:

57178

result:

ok single line: '57178'

Test #32:

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

input:

cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccchhcccccchcccccccccccccccccccchccccccccccccccchccccccccccccccccccccccchccccccccccccccccccccccchcccccccchccccccccccccccccccccccccccccccccchcccchcccccccccccccccccccccccccchcccccccccccchccccccchcccccccccccc...

output:

35623

result:

ok single line: '35623'

Test #33:

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

input:

cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc...

output:

23657

result:

ok single line: '23657'

Test #34:

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

input:

dddcdddddddddddddddcdddddddddddddddddhddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddsddddddddddddddddddddddddd...

output:

69

result:

ok single line: '69'

Test #35:

score: 0
Accepted
time: 2ms
memory: 3824kb

input:

cccccccccchccccccccccccccccccccccccccccccccccccchhshhhhhhhhshhhhhhhhdhhhhhhhhhhhhhhhhhhhhhhhhhhhhhdddddddddddddddddddddddddddddddddddcddddddddddddddssssssssshssscssssssssscssssshssssssssssssssssssssss

output:

9

result:

ok single line: '9'

Test #36:

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

input:

cchhdhssdcddchccddhsdsshcdhhdhdccshcssss

output:

21

result:

ok single line: '21'