QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#745482 | #9568. Left Shifting 3 | eastcloud# | WA | 7ms | 3956kb | C++17 | 1.6kb | 2024-11-14 10:15:30 | 2024-11-14 10:15:35 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define cpy(x,y,s) memcpy(x,y,sizeof(x[0])*(s))
#define mset(x,v,s) memset(x,v,sizeof(x[0])*(s))
#define all(x) begin(x),end(x)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ary array
#define eb emplace_back
#define IL inline
using namespace std;
#define N 500005
int read(){
int x=0,f=1;char ch=getchar();
while(ch<'0' || ch>'9')f=(ch=='-'?-1:f),ch=getchar();
while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
return x*f;
}
void write(int x){
if(x<0)x=-x,putchar('-');
if(x/10)write(x/10);
putchar(x%10+'0');
}
deque<char> q;
char s[N],c[7]={'n','a','n','j','i','n','g'};
void solve(){
while(q.size())q.pop_front();
int n=read(),k=read();k=min(k,n-1);
scanf("%s",s+1);
if(n<7){write(0);putchar('\n');return;}
for(int i=1;i<=n;i++)q.push_back(s[i]);
int ans=0,res=0;
auto calc=[&](int p){
for(int j=0;j<7;j++){
if(q[j+p]==c[j]);
else return 0;
}
return 1;
};
for(int i=0;i+6<q.size();i++)ans+=calc(i);
res=max(res,ans);
for(int i=1;i<=k;i++){
ans-=calc(0);if(q.size()-7!=0)ans-=calc(q.size()-7);
q.push_back(q.front());q.pop_front();
ans+=calc(0);if(q.size()-7!=0)ans+=calc(q.size()-7);res=max(res,ans);
}
write(res);putchar('\n');
}
int main(){
#ifdef EAST_CLOUD
freopen("a.in","r",stdin);
//freopen("a.out","w",stdout);
#endif
int T=read();while(T--)solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
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: 7ms
memory: 3956kb
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:
4 0 3 3 3 3 3 4 4 4 0 3 5 4 3 2 1 1 5 2 0 3 3 0 0 1 0 0 0 7 4 0 1 3 1 2 2 1 1 1 3 4 2 3 2 0 1 2 5 1 2 1 2 1 2 4 0 1 0 0 1 1 3 2 2 1 0 3 1 2 1 1 4 5 1 1 1 1 0 1 1 2 2 2 0 6 6 4 1 1 2 1 2 1 1 6 2 4 0 1 2 1 3 5 3 3 4 4 1 3 3 2 5 1 2 0 0 1 0 6 0 3 0 5 2 0 3 3 3 3 2 2 0 1 1 1 3 4 1 3 3 0 1 1 2 2 3 1 0 4 ...
result:
wrong answer 1st numbers differ - expected: '3', found: '4'