QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#725996#9568. Left Shifting 3wxgmjfhy#WA 24ms3952kbC++20704b2024-11-08 21:08:182024-11-08 21:08:19

Judging History

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

  • [2024-11-08 21:08:19]
  • 评测
  • 测评结果:WA
  • 用时:24ms
  • 内存:3952kb
  • [2024-11-08 21:08:18]
  • 提交

answer

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

int n,k;
string s;

string st="nanjing";

inline void solve(){
    cin>>n>>k;

    cin>>s;

    k=min(k,n);

    for(int i=0;i<k;i++)s=s+s[i];

    n=s.size();

    int ans=0;

    for(int i=0;i+6<n;i++){
        if(s[i]=='n'){
            int flag=1;
            for(int t=0,j=i;t<7;t++,j++){
                if(s[j]!=st[t]){
                    flag=0;
                    break;
                }
            }        
            ans+=flag;
        }
    }

    cout<<ans<<"\n";
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t=1;
    cin>>t;
    while(t--)solve();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 24ms
memory: 3952kb

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
6
4
6
4
0
4
8
5
4
2
1
1
7
3
0
5
5
0
0
1
0
0
0
10
8
0
1
4
1
3
3
1
1
1
3
3
1
3
3
0
1
2
8
1
2
1
3
1
2
5
0
1
0
0
2
1
3
2
3
1
0
3
1
3
1
1
4
7
1
1
1
1
0
1
2
2
1
3
0
8
8
6
1
1
2
1
2
1
1
9
2
7
0
2
4
1
3
7
3
5
6
6
1
3
4
2
6
1
3
0
0
1
0
9
0
4
0
6
2
0
2
4
3
4
2
3
0
1
1
1
3
4
1
3
3
0
1
1
2
4
2
1
0
6...

result:

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