QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#727406#9568. Left Shifting 3ucup-team4938#WA 0ms4140kbC++141.3kb2024-11-09 13:07:452024-11-09 13:07:45

Judging History

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

  • [2024-11-09 13:07:45]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4140kb
  • [2024-11-09 13:07:45]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define mod 998244353ll
#define pii pair<int,int>
#define fi first
#define se second
#define mems(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define db double
using namespace std;
const int maxn=400010;
const int inf=1e18;
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch-48);ch=getchar();}
	return x*f;
}
bool Mbe;

int n,k,ans;
char s[maxn];
bool vis[maxn];
int sum[maxn];
int calc(int l,int r){
	if(l>r)return 0;
	return sum[r]-sum[l-1];
}
void work(){
	n=read();k=read();ans=0;
	for(int i=1;i<=n;i++)vis[i]=0;
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)s[i+n]=s[i];
	for(int i=1;i<=n;i++)if(s[i]=='n'&&s[i+1]=='a'&&s[i+2]=='n'&&s[i+3]=='j'&&s[i+4]=='i'&&s[i+5]=='n'&&s[i+6]=='g')vis[i]=vis[i+n]=1;
	for(int i=1;i<=2*n;i++)sum[i]=sum[i-1]+vis[i];
	k=min(n,k);
	for(int i=0;i<=k;i++){
		ans=max(ans,calc(i+1,n-6+i));
	}
	printf("%lld\n",ans);
}

// \
444

bool Med;
int T;
signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	
//	ios::sync_with_stdio(0);
//	cin.tie(0);cout.tie(0);
	
//	cerr<<(&Mbe-&Med)/1048576.0<<" MB\n";
	
	T=read();
	while(T--)work();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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
Wrong Answer
time: 0ms
memory: 4140kb

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
3
4
2
3
9
4
13
4
0
4
15
6
15
19
1
1
20
3
0
13
19
0
0
1
0
0
0
24
24
0
1
4
1
22
3
1
1
1
3
3
1
3
16
0
1
2
24
2
2
2
17
1
2
17
0
1
0
0
2
1
3
2
28
33
0
3
1
5
1
1
4
38
1
1
1
1
0
1
3
5
1
5
0
23
22
31
2
1
2
1
3
1
1
35
3
35
0
1
12
1
3
38
3
11
35
29
1
3
39
22
34
1
3
0
0
1
0
36
0
6
0
38
2
0
2
30
3
3
1
13
0
...

result:

wrong answer 4th numbers differ - expected: '2', found: '4'