QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#726762#9568. Left Shifting 3ucup-team3555#RE 0ms3620kbC++17567b2024-11-09 08:15:212024-11-09 08:15:21

Judging History

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

  • [2024-11-09 08:15:21]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3620kb
  • [2024-11-09 08:15:21]
  • 提交

answer

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

typedef long long ll;
const int N=1e6+3;
int n,k,nb[N];
char ch[N];
bool Chk(int x)
{
	string t="";
	for(int i=0;i<=6;i++)t+=ch[x+i];
	return t=="nanjing"; 
}
void Solve()
{
	cin>>n>>k>>ch;int ans=0;
	for(int i=0;i<n;i++)ch[i+n]=ch[i];
	if(n<7){cout<<0<<endl;return;}
	for(int i=0;i<2*n;i++)nb[i]=nb[i-1]+Chk(i);
	for(int i=0;i<=k;i++)ans=max(ans,nb[i+n-7]-(i==0?0:nb[i-1]));
	cout<<ans<<"\n";
}
int main()
{
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int T;cin>>T;
	while(T--)Solve();
}

詳細信息

Test #1:

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

input:

4
21 10
jingicpcnanjingsuanan
21 0
jingicpcnanjingsuanan
21 3
nanjingnanjingnanjing
4 100
icpc

output:

2
1
3
0

result:

ok 4 number(s): "2 1 3 0"

Test #2:

score: -100
Runtime Error

input:

2130
39 7
nnananjingannanjingngnanjinganjinggjina
1 479084228
g
33 2
gqnanjinggrjdtktnanjingcvsenanjin
24 196055605
ginganjingnanjingnanjing
23 3
ngnanjinganjingjinnanji
40 3
njingaaznannanjingnananjingyonwpnanjinga
40 207842908
nanjinggphconanjingkonanjinannanjinglxna
46 3
ingjingnnanjingnanjinging...

output:

3
0

result: