Logo Wy Online Judge

WyOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#565#112. 【0621 模拟赛】7KrokodsBase_ring_tree10012ms3460kbC++14643b2025-06-21 14:25:502025-06-21 23:48:13

answer

#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
int a,b,c,d;
int n,m;
string s;
int ans;
int dfs(int m1,int x,int y,int z,int q)
{
	if(m1==0)
	{
		ans=max(ans,x*x+y*y+z*z+q*q+min(x/2,min(y,min(z/2,q)))*7);
        return ans;
	}
	dfs(m1-1,x+1,y,z,q);
	dfs(m1-1,x,y+1,z,q);
	dfs(m1-1,x,y,z+1,q);
	dfs(m1-1,x,y,z,q+1);
}
signed main()
{
	cin>>n>>m;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='k')
		{
			a++;
		}
		if(s[i]=='r')
		{
			b++;
		}
		if(s[i]=='o')
		{
			c++;
		}
		if(s[i]=='d')
		{
			d++;
		}
	}
	dfs(m,a,b,c,d);
	cout<<ans;
	return 0;
}

Details

小提示:点击横条可展开更详细的信息

Subtask #1:

score: 17
Accepted

Test #1:

score: 17
Accepted
time: 0ms
memory: 3280kb

input:

56 0
kkkkkkkkkkoooooooooorrrrrdddddkkkkkkkkkkooooooooookkkkoo

output:

1145

result:

ok "1145"

Test #2:

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

input:

4 0
dkor

output:

4

result:

ok "4"

Test #3:

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

input:

11 0
krokodkroko

output:

44

result:

ok "44"

Test #4:

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

input:

10 0
kkkkkkkkkk

output:

100

result:

ok "100"

Test #5:

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

input:

100 0
krokodkrodkrokodkrodkrokodkrodkrokodkrodkrokodkrodkrokodkrodkrokodkrodkrokodkrodkrokodkrodkrok...

output:

2705

result:

ok "2705"

Subtask #2:

score: 26
Accepted

Test #6:

score: 26
Accepted
time: 1ms
memory: 3292kb

input:

8 1
kodrrrrr

output:

39

result:

ok "39"

Test #7:

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

input:

5 1
kroko

output:

17

result:

ok "17"

Test #8:

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

input:

11 1
krokodkroko

output:

54

result:

ok "54"

Test #9:

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

input:

87 1
kkkokokokokdokdokodkodkdokdokdokdodkodkokokdodkorkrrrrrrrrrrrrrrrrrrrrdkokokokdrokrodkk

output:

2099

result:

ok "2099"

Subtask #3:

score: 7
Accepted

Test #10:

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

input:

5 3
dodor

output:

30

result:

ok "30"

Test #11:

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

input:

3 3
kro

output:

18

result:

ok "18"

Test #12:

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

input:

2 4
rd

output:

26

result:

ok "26"

Test #13:

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

input:

100 10
krokokdokorkokodkokrokokdorkokokdkdkkdkdrrrrddrkdokodkrokdorkdokdrokrdordkordkdrokdrokdrokdro...

output:

3415

result:

ok "3415"