QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#802910#9568. Left Shifting 3JJJ_WA 1ms4424kbC++141011b2024-12-07 15:10:552024-12-07 15:10:55

Judging History

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

  • [2024-12-07 15:10:55]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4424kb
  • [2024-12-07 15:10:55]
  • 提交

answer

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<bits/stdc++.h>
using namespace std;
int f[200004];
int main(){
	int t;
	cin>>t;
	while(t--){
		int n,k,ans=0;
		string s;
        cin>>n>>k;
        if(k>n) k=n;
        cin>>s;
        s=' '+s;
		memset(f,0,sizeof(f));
		//for(int i=1;i<=n;i++){
		//	cin>>s[i];
			//s[i+n]=s[i];
		//}
		//cout<<s<<endl;
		/*for(int i=1;i<=n+k;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'){
				if(f[l]!=0 && i%f[l]==0) l++;
				f[r++]=i;
				cout<<l<<' '<<r<<' '<<i<<' '<<endl; 
			}
		}
		cout<<r-l+1<<endl;*/
		for(int i=0;i+6<2*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') 
			   f[i]++;
            f[i+1]+=f[i];
        }
        for(int i=0;i<=k;i++)
            ans=max(ans,f[max(n+i-6,0)]-f[i]);
        cout<<ans<<endl;
	} 
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 4424kb

input:

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

output:

1
1
3
0

result:

wrong answer 1st numbers differ - expected: '2', found: '1'