QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#805072 | #9568. Left Shifting 3 | Dylan114514 | AC ✓ | 3ms | 8004kb | C++14 | 816b | 2024-12-08 12:52:14 | 2024-12-08 12:52:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
int n,T,a[N],cnt[3],k,sum[N];
char s[N],ch[N];
bool ppp(int x){
for(int i=x-7+1,j=1;i<=x;++j,++i){
if(s[i]!=ch[j])return 0;
}
return 1;
}
signed main(){
// ios::sync_with_stdio(0);
ch[1]='n',ch[2]='a',ch[3]='n',ch[4]='j',ch[5]='i',ch[6]='n',ch[7]='g';
scanf("%d",&T);
while(T--){
scanf("%d%d",&n,&k);
scanf("%s",s+1);
for(int i=1;i<=n+min(7,k);++i){
sum[i]=0;
}
for(int i=1;i<=min(7,k);++i)s[i+n]=s[i];
for(int i=7;i<=n+min(7,k);++i){
if(ppp(i)){
++sum[i];
// cout<<i<<endl;
}
}
for(int i=1;i<=n+min(7,k);++i){
sum[i]+=sum[i-1];
}
// cout<<sum[n]<<endl;
int ans=0;
for(int i=1;i<=min(k,7)+1;++i){
ans=max(ans,sum[i+n-1]-sum[i+5]);
}
printf("%d\n",ans);
}
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 8004kb
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: 3ms
memory: 7924kb
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: 0ms
memory: 7988kb
input:
3 100000 998244353 gbppzfsncqyzmuwrcvtxsciucxusskcjhaanwhqmyncytwhkubrvcqxgcehdxyewdyvpqjcmrnmlgrytrucexmmfulqbtfctehphmrzkosyvhtvjrromqncbgsjcwhmlqidkycaxyhsrduoxayntuhqubvboseeziwjvrfagsbvtxjjbexnajqapgxydwtztzbbdpoydnjipfizdfpmczgqvdmpvxbqubtygkfpdeonegfzsttirbhzkobbigwneyvtcxndfkljdvbbcfnadtfhgo...
output:
4 1649 3651
result:
ok 3 number(s): "4 1649 3651"
Extra Test:
score: 0
Extra Test Passed