QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#100495 | #5562. Jesting Jabberwocky | PetroTarnavskyi# | AC ✓ | 25ms | 3568kb | C++17 | 813b | 2023-04-26 16:39:33 | 2023-04-26 16:39:34 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define MP make_pair
#define PB push_back
#define F first
#define S second
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
vector<char> v = {'c', 'd', 'h', 's'};
string s;
cin >> s;
int ans = SZ(s);
do
{
VI dp(4, 0);
FOR(i, 0, SZ(s))
{
int j = 0;
while (s[i] != v[j]) j++;
dp[j]++;
FOR(k, j, 4) dp[k] = max(dp[k], dp[j]);
}
ans = min(ans, SZ(s) - *max_element(ALL(dp)));
}while (next_permutation(ALL(v)));
cout << ans << '\n';
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3380kb
input:
hccdhcd
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 2ms
memory: 3396kb
input:
cchhdshcdshdcsh
output:
7
result:
ok single line: '7'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3364kb
input:
c
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 2ms
memory: 3436kb
input:
cchhhddss
output:
0
result:
ok single line: '0'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3332kb
input:
chchchch
output:
3
result:
ok single line: '3'
Test #6:
score: 0
Accepted
time: 2ms
memory: 3360kb
input:
cccchhccddcccccsscccc
output:
6
result:
ok single line: '6'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3292kb
input:
shhssdsddsddcddhchss
output:
8
result:
ok single line: '8'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3324kb
input:
cshhscshdscscchssshs
output:
9
result:
ok single line: '9'
Test #9:
score: 0
Accepted
time: 2ms
memory: 3368kb
input:
hchdschhdhchhdcssccs
output:
8
result:
ok single line: '8'
Test #10:
score: 0
Accepted
time: 2ms
memory: 3420kb
input:
chchcsdcchdhdcsdssdh
output:
9
result:
ok single line: '9'
Test #11:
score: 0
Accepted
time: 3ms
memory: 3288kb
input:
shhdhchcdhcssdcssdss
output:
8
result:
ok single line: '8'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3328kb
input:
ddcdsdsddhshdshhchdh
output:
8
result:
ok single line: '8'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3288kb
input:
sdhsccsshchsshsshshs
output:
8
result:
ok single line: '8'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3324kb
input:
cdddccdssdhhhshdcchh
output:
7
result:
ok single line: '7'
Test #15:
score: 0
Accepted
time: 2ms
memory: 3360kb
input:
ddcddhdshdhdcdcshcss
output:
8
result:
ok single line: '8'
Test #16:
score: 0
Accepted
time: 2ms
memory: 3420kb
input:
csddhhshhddsdccdcsds
output:
8
result:
ok single line: '8'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3356kb
input:
hdcshcscdhddhhdshchc
output:
10
result:
ok single line: '10'
Test #18:
score: 0
Accepted
time: 2ms
memory: 3328kb
input:
hchshdcdshddshshshdc
output:
9
result:
ok single line: '9'
Test #19:
score: 0
Accepted
time: 2ms
memory: 3416kb
input:
ccddhsddccdshdcddddd
output:
7
result:
ok single line: '7'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3356kb
input:
ssdssccdhdsdsdccshcc
output:
8
result:
ok single line: '8'
Test #21:
score: 0
Accepted
time: 23ms
memory: 3420kb
input:
schhchsshscsdschhshddsdhchchshddhddchchdsdchcddddshcscsdhscsddchdcscshdsdddhsdhdchcdcdcsdhhshcsccdchhschshhsdschhhcdchsshdcdhschhdchcddcccchdhcchshhcshdshdssdddhcchdccddhcsshhcdddcdhcchdhddchdshshcscdsdcchchdhcshhscsdchhsdcdhdshdcsdhhhdcddcscdddssccdddccscsdcscchdcsdccdscdshhccchdsscdhhsccsssdcdcsdc...
output:
67475
result:
ok single line: '67475'
Test #22:
score: 0
Accepted
time: 17ms
memory: 3452kb
input:
hsccchcdssddsschddchdcdhdhshccchddcshdcsdcdcccshscccchhhdccshhhsdhcchddhdshssdsccdshdshdcccccchsdhhsdhdscdccdscddcccsssdddshsdhcdcsshhdsshssshdhhhsdcshcccdcsscdhdddhsdsshhddchsdhsssdscddcsccsshccccccshhchdhhhchcccsddchhdhhcschssdccshdscdhhhdsdshdhssdsshdhddcchhhhddchhsssdsdchshscccschcdchchhdcdhscdh...
output:
62915
result:
ok single line: '62915'
Test #23:
score: 0
Accepted
time: 4ms
memory: 3424kb
input:
hshhcsshsdsdchsshdssdchdcsdshccdsshdchsshhcssshcshshhcddhshsdhdcsdhchshdhchhsschhscdhccdcschcsdhddddchchddhhscssccdhhhhhcdchhhhshhdchchcchcshdhdhcddcdhschddsssdcsdhhdsccddcdhcccsshdshshcchschddchshshsdhdhcsdchdchdsssscdschccssdhschcccssddsshhdchhsscdsshcdssdssscsscdhchcsdcchscdsdhhsdshhhccddhsshhdds...
output:
24067
result:
ok single line: '24067'
Test #24:
score: 0
Accepted
time: 2ms
memory: 3296kb
input:
sssdsdchhshdcsccdhdsddsdshchhschdhsschhsshchdcsscdchsshschhsscdshschcddshdsdddshcdhhsscsdchcshddchsdschhdhhdscscsdsdhcdsccdhhshhchshshccccshdcdddddddshsdchchcsddhcchchhsdhcddcsshcsshdhdhscsdhsdshhcdddcshsdhshhssddcdchdsdhcdshsschdschdhdccdhshcdhhhhddcchddchsdhhsccddsdcsscdhhsdscshccssschdsdchccdcdhh...
output:
638
result:
ok single line: '638'
Test #25:
score: 0
Accepted
time: 25ms
memory: 3484kb
input:
hdhccsdhdddcddcdccddddsssdccchshhcchshhschcdsdcdssscshdsschdhshdsdhsschccshscchcddcdhdchsdccdsshdsdchddsccddcsddhcsdchdccsccddshhdchsdddscsdhcccshhdscscshsssscdcschdhscssddscshcddccchsddcchcdhsscdchdhdchsccschcdsdscdhddcdssdddhhsdsdccdshshdschdhhhscshssccdhsddhsdhshchhhhcschdssdddhcdddhdshhcdhhsschd...
output:
74459
result:
ok single line: '74459'
Test #26:
score: 0
Accepted
time: 25ms
memory: 3424kb
input:
dhdssscccshcdhhcsdhhdcschhshcchdcsddshshchhhchddhsshcdddsssdsshscscshdsdccshdscschsdscdhhshhdhhhhdhshhdhsdhhccchccchhhcschshdcddhssdsdsddccdsshdchcsdhhdcsdddcshhcdhchcscsdhchhhcdsdddsdccdddhdhddsscsddsddschshdssccchcshhscshddhdhdsddcdddsscdcsdhsdddhscdsshcscdcdhdssdhdscdchcsdhscshcdsshcdchcsdhsdhddd...
output:
74427
result:
ok single line: '74427'
Test #27:
score: 0
Accepted
time: 25ms
memory: 3496kb
input:
hcdchhsdcshhhhcsscsdsdcshchdhhdcchccdchsdsddchcdchdcssshhcdhchsdccsschshcssshdshcdchdshhhcchscshccsshdddcshsccddsshchhsddshccsshsddcdscccddhcsddssccdchsshccshsdsscsdcdssdhhddcccchhsssdhscdhshccsshddcsdshcdddshdshhddchdscscdhhhhddcsddchhcccdshcdcccddscscdsccchhccdddcscscdhsdhhhchcccdccddsdhhchhchdcsh...
output:
74431
result:
ok single line: '74431'
Test #28:
score: 0
Accepted
time: 25ms
memory: 3548kb
input:
cdcdshhhhdsshdsdchhccdcsshsdsshdhshdshhddsdshdchsccsccdhcdshsdscdcdcsshhsdchsscdsshcshssdddshcdsscchhddhchsdsshccdhchdhhhcchdhccscshcchcchddhccscdhsdhsshsssddddcchdchssddhchsdhhdsccsdsdhchchhcchdchhscddcsdcdsddcddchdcshchschdhdhchddccchchcshccsdcccdcdcdhsddddchchshchdhsshhdhccsdhhcdscsscsshchcdhcdhc...
output:
74497
result:
ok single line: '74497'
Test #29:
score: 0
Accepted
time: 2ms
memory: 3436kb
input:
dcshshcdschdschdhscdcdshhdcsdhcsshdcshdcchsddhcshcsdsdchdchshcsdscdhhdsccsdhhdcsshdchscddshcsdchsdhc
output:
72
result:
ok single line: '72'
Test #30:
score: 0
Accepted
time: 16ms
memory: 3500kb
input:
chdsdhcscdhscdhsdcshsdchshdcdhcssdchhcdsdchsdchsschdhcsdchsddschcshdcsdhhcsddchssdhcchsdscdhschdchdsdchsdshcshcdcshdscdhhsdchcsdhdschdscshcddschhcdsdschhscddshcshdcshcdschdhcsdcdshshdchdschdcsdchscshddcshscdhcdshdshcchsdshdchcsddcshschddschcdshdshcdshcsdhcchdsdschsdchhdscchsddschdhsccdshhsdcdschhdcs...
output:
74997
result:
ok single line: '74997'
Test #31:
score: 0
Accepted
time: 22ms
memory: 3568kb
input:
cccccccccccscccccccccccccccccccccccccccsccccccccccccccccccccccccccccccccccccccccccccccsccccccccccccccccsccccccccccccccsccccccsccccsccchcsccsccccccccsccccccccccccccccsccccccscccccssscccccccccccccccscccccccccsccccccscccccccccsccsccccccccccccccccsccscchccccscccccccsccscccccccscccccccccccsccsccccccscccc...
output:
57178
result:
ok single line: '57178'
Test #32:
score: 0
Accepted
time: 14ms
memory: 3516kb
input:
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccchhcccccchcccccccccccccccccccchccccccccccccccchccccccccccccccccccccccchccccccccccccccccccccccchcccccccchccccccccccccccccccccccccccccccccchcccchcccccccccccccccccccccccccchcccccccccccchccccccchcccccccccccc...
output:
35623
result:
ok single line: '35623'
Test #33:
score: 0
Accepted
time: 14ms
memory: 3488kb
input:
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc...
output:
23657
result:
ok single line: '23657'
Test #34:
score: 0
Accepted
time: 2ms
memory: 3312kb
input:
dddcdddddddddddddddcdddddddddddddddddhddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddsddddddddddddddddddddddddd...
output:
69
result:
ok single line: '69'
Test #35:
score: 0
Accepted
time: 1ms
memory: 3320kb
input:
cccccccccchccccccccccccccccccccccccccccccccccccchhshhhhhhhhshhhhhhhhdhhhhhhhhhhhhhhhhhhhhhhhhhhhhhdddddddddddddddddddddddddddddddddddcddddddddddddddssssssssshssscssssssssscssssshssssssssssssssssssssss
output:
9
result:
ok single line: '9'
Test #36:
score: 0
Accepted
time: 0ms
memory: 3432kb
input:
cchhdhssdcddchccddhsdsshcdhhdhdccshcssss
output:
21
result:
ok single line: '21'