QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#727531 | #9568. Left Shifting 3 | ucup-team5296# | TL | 0ms | 3764kb | C++20 | 1.4kb | 2024-11-09 13:20:43 | 2024-11-09 13:20:44 |
Judging History
answer
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <ctime>
#include <cstdio>
#include <random>
#include <vector>
#include <bitset>
#include <cassert>
#include <cstring>
#include <algorithm>
#define fi first
#define se second
#define MISAKA main
#define ll long long
#define eb emplace_back
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define _rep(i,a,b) for(int i=a;i>=b;--i)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define FIO(FILE) freopen(FILE".in","r",stdin),freopen(FILE".out","w",stdout)
using namespace std;
inline int read(){
char ch=getchar();int f=1,x=0;
while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
return x*f;
}
const int N=4e5+10,mod=998244353;
int n,k,pre[N],suf[N];char s[N];
bool ck(int x){
string t;
rep(i,x,x+6) t+=s[i];
return t=="nanjing";
}
void misaka(){
rep(i,1,n) pre[i]=suf[i]=0,s[i]=s[i+n]=0;
scanf("%d%d%s",&n,&k,s+1);
rep(i,1,n) s[i+n]=s[i];
rep(i,7,n) pre[i]=max(pre[i-7]+ck(i-6),pre[i-1]);
_rep(i,n-6,1) suf[i]=max(suf[i+7]+ck(i),suf[i+1]);
int ans=pre[n];
rep(i,1,min(k,n-1)){
int cnt=0;
rep(j,max(n-5,1),n+i-6) cnt+=ck(j);
ans=max(ans,suf[i+1]+pre[i]+cnt);
}
printf("%d\n",ans);
}
signed MISAKA(){
int T=read();
while(T--) misaka();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3764kb
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
Time Limit Exceeded
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 3 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 1 2 1 3 0 8 8 6 1 1 2 1 2 1 1 9 2 7 0 1 3 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 3 2 1 0 6...