QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#743922#9568. Left Shifting 3huang123zsAC ✓11ms4064kbC++14852b2024-11-13 20:19:182024-11-13 20:19:20

Judging History

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

  • [2024-11-13 20:19:20]
  • 评测
  • 测评结果:AC
  • 用时:11ms
  • 内存:4064kb
  • [2024-11-13 20:19:18]
  • 提交

answer

#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N=2.1e5;
inline LL read(){
	LL x=0,ff=1;
	char c=getchar();
	while(!isdigit(c)&&c!='-') c=getchar();
	if(c=='-') c=getchar(),ff=-1;
	while(isdigit(c)) x=x*10ll+c-'0',c=getchar();
	return x*ff;
}
int n,m;
char c[N],s[7];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int casecnt=read();
	s[0]='n',s[1]='a',s[2]='n',s[3]='j',s[4]='i',s[5]='n',s[6]='g';
	while(casecnt--){
		n=read(),m=read(); 
		m=min(m,7);
		scanf("%s",c);
		int cnt[3]={0,0,0},ans=0;
		for(int d=0;d<=m;++d){
			int res=0;
			for(int i=0;i<n-6;++i){
				int j=0;
				for(;j<7;++j)
					if(s[j]!=c[(d+i+j)%n])
						break;
//				if(j==7)
//					cerr<<i<<endl;
				res+=j==7;
			}
			ans=max(ans,res);
		}
		printf("%d\n",ans);
	} 
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 0
Accepted
time: 7ms
memory: 3892kb

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
2
2
3
3
4
3
4
0
2
4
3
2
1
1
1
4
2
0
3
3
0
0
1
0
0
0
5
4
0
1
2
1
2
2
1
1
1
3
3
1
3
2
0
1
2
4
1
2
1
2
1
2
3
0
1
0
0
1
1
3
2
2
1
0
3
1
2
1
1
4
4
1
1
1
1
0
1
1
1
1
2
0
4
4
3
1
1
2
1
1
1
1
5
1
4
0
1
2
1
3
4
3
3
3
3
1
3
2
1
3
1
2
0
0
1
0
5
0
2
0
3
1
0
2
2
3
2
1
2
0
1
1
1
2
4
1
3
2
0
1
1
2
2
2
1
0
3
...

result:

ok 2130 numbers

Test #3:

score: 0
Accepted
time: 11ms
memory: 4064kb

input:

3
100000 998244353
gbppzfsncqyzmuwrcvtxsciucxusskcjhaanwhqmyncytwhkubrvcqxgcehdxyewdyvpqjcmrnmlgrytrucexmmfulqbtfctehphmrzkosyvhtvjrromqncbgsjcwhmlqidkycaxyhsrduoxayntuhqubvboseeziwjvrfagsbvtxjjbexnajqapgxydwtztzbbdpoydnjipfizdfpmczgqvdmpvxbqubtygkfpdeonegfzsttirbhzkobbigwneyvtcxndfkljdvbbcfnadtfhgo...

output:

4
1649
3651

result:

ok 3 number(s): "4 1649 3651"

Extra Test:

score: 0
Extra Test Passed