QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#726762 | #9568. Left Shifting 3 | ucup-team3555# | RE | 0ms | 3620kb | C++17 | 567b | 2024-11-09 08:15:21 | 2024-11-09 08:15:21 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+3;
int n,k,nb[N];
char ch[N];
bool Chk(int x)
{
string t="";
for(int i=0;i<=6;i++)t+=ch[x+i];
return t=="nanjing";
}
void Solve()
{
cin>>n>>k>>ch;int ans=0;
for(int i=0;i<n;i++)ch[i+n]=ch[i];
if(n<7){cout<<0<<endl;return;}
for(int i=0;i<2*n;i++)nb[i]=nb[i-1]+Chk(i);
for(int i=0;i<=k;i++)ans=max(ans,nb[i+n-7]-(i==0?0:nb[i-1]));
cout<<ans<<"\n";
}
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T;cin>>T;
while(T--)Solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
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
Runtime Error
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