QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#727590#9568. Left Shifting 3ucup-team4508#WA 12ms5624kbC++14988b2024-11-09 13:24:562024-11-09 13:24:57

Judging History

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

  • [2024-11-09 13:24:57]
  • 评测
  • 测评结果:WA
  • 用时:12ms
  • 内存:5624kb
  • [2024-11-09 13:24:56]
  • 提交

answer

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

using ui = unsigned;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,l,r) for(int i=(l);i>=(r);--i)
#define repn(i,n) for(int i=0;i<(n);++i)
#define sizc(x) ((int)(x).size())
#define allc(x) (x).begin(),(x).end()
#define fir first
#define sec second

constexpr int N = 2e5+5;

int n,m;
char s[N*3];
int p[N*3];

void solve(){
    cin>>n>>m;m=min(m,n-1);
    rep(i,1,n)cin>>s[i],s[i+n]=s[i+2*n]=s[i];
    rep(i,1,3*n)p[i]=0;
    string t="nanjing";
    rep(i,1,3*n-6){
        p[i]=1;
        repn(j,7)if(s[i+j]!=t[j])p[i]=0;
        p[i]+=p[i-1];
    }
    int ans=0;
    rep(i,1,m+1)ans=max(ans,p[i+n-7]-p[i-1]);
    cout<<ans<<'\n';;
}

signed main(){
	// freopen(".in","r",stdin);
	// freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

    int T;cin>>T;
    while(T--)solve();
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5624kb

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: 12ms
memory: 3700kb

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

result:

wrong answer 2nd numbers differ - expected: '0', found: '32648'