ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#548 | #112. 【0621 模拟赛】7Krokods | Jtwang1 | 100 | 19ms | 3468kb | C++14 | 819b | 2025-06-21 14:12:31 | 2025-06-21 23:47:48 |
answer
#include<iostream>
#define endl '\n'
using namespace std;
const int inf=0x3f3f3f3f3f3f3f3f;
int cnt[10];
int turn(char c){
if(c=='d') return 0;
else if(c=='k') return 1;
else if(c=='o') return 2;
else return 3;
}
int need(int c){
if(c==0) return 1;
else if(c==1) return 2;
else if(c==2) return 2;
else return 1;
}
int n,m,ans;
string s;
void dfs(int x){
if(x==m+1){
int sum=0;
for(int i=0;i<4;i++) sum+=cnt[i]*cnt[i];
int tmp=1e9;
for(int i=0;i<4;i++) tmp=min(tmp,cnt[i]/need(i));
sum+=tmp*7;
ans=max(ans,sum);
return;
}
for(int i=0;i<4;i++){
cnt[i]++;
dfs(x+1);
cnt[i]--;
}
}
int main(){
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
cin>>n>>m;
cin>>s;
for(int i=0;i<n;i++) cnt[turn(s[i])]++;
dfs(1);
cout<<ans;
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 17
Accepted
Test #1:
score: 17
Accepted
time: 0ms
memory: 3408kb
input:
56 0 kkkkkkkkkkoooooooooorrrrrdddddkkkkkkkkkkooooooooookkkkoo
output:
1145
result:
ok "1145"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3292kb
input:
4 0 dkor
output:
4
result:
ok "4"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3172kb
input:
11 0 krokodkroko
output:
44
result:
ok "44"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3292kb
input:
10 0 kkkkkkkkkk
output:
100
result:
ok "100"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3292kb
input:
100 0 krokodkrodkrokodkrodkrokodkrodkrokodkrodkrokodkrodkrokodkrodkrokodkrodkrokodkrodkrokodkrodkrok...
output:
2705
result:
ok "2705"
Subtask #2:
score: 26
Accepted
Test #6:
score: 26
Accepted
time: 1ms
memory: 3172kb
input:
8 1 kodrrrrr
output:
39
result:
ok "39"
Test #7:
score: 0
Accepted
time: 1ms
memory: 3316kb
input:
5 1 kroko
output:
17
result:
ok "17"
Test #8:
score: 0
Accepted
time: 1ms
memory: 3348kb
input:
11 1 krokodkroko
output:
54
result:
ok "54"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3348kb
input:
87 1 kkkokokokokdokdokodkodkdokdokdokdodkodkokokdodkorkrrrrrrrrrrrrrrrrrrrrdkokokokdrokrodkk
output:
2099
result:
ok "2099"
Subtask #3:
score: 7
Accepted
Test #10:
score: 7
Accepted
time: 0ms
memory: 3288kb
input:
5 3 dodor
output:
30
result:
ok "30"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3468kb
input:
3 3 kro
output:
18
result:
ok "18"
Test #12:
score: 0
Accepted
time: 0ms
memory: 3452kb
input:
2 4 rd
output:
26
result:
ok "26"
Test #13:
score: 0
Accepted
time: 15ms
memory: 3288kb
input:
100 10 krokokdokorkokodkokrokokdorkokokdkdkkdkdrrrrddrkdokodkrokdorkdokdrokrdordkordkdrokdrokdrokdro...
output:
3415
result:
ok "3415"