QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#779295#9568. Left Shifting 3Idtwtei#WA 2ms3828kbC++14620b2024-11-24 18:17:082024-11-24 18:17:09

Judging History

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

  • [2024-11-24 18:17:09]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3828kb
  • [2024-11-24 18:17:08]
  • 提交

answer

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

const int N=2e5+100;
#define gc getchar()
#define rd read()
inline int read(){
	int x=0,f=0; char c=gc;
	for(;c<'0'||c>'9';c=gc) f|=(c=='-');
	for(;c>='0'&&c<='9';c=gc) x=(x<<1)+(x<<3)+(c^48);
	return f?-x:x;
}

int n,K,ans=0; string s,nj="nanjing"; char _s[N];

void solve(){
	n=rd,K=rd,ans=0,scanf("%s", _s),s=_s;
	for(int i=0;i+6<n;++i) if(s.substr(i,7)==nj) ++ans;
	for(int i=1;i<=K&&i<=n&&i<=7;++i) if(n>=7&&s.substr(n-7+i)+s.substr(0,i)==nj) ++ans;
	printf("%d\n", ans);
}

int main(){
		
	int T=rd;
	while(T--) solve(); 
		 
	return 0;
}

详细

Test #1:

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

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: 2ms
memory: 3828kb

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

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