QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#727552 | #9568. Left Shifting 3 | ucup-team5296# | AC ✓ | 53ms | 6780kb | C++20 | 1.4kb | 2024-11-09 13:22:23 | 2024-11-09 13:22:30 |
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),min(n+i-6,n)) 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;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3804kb
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: 44ms
memory: 3888kb
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: 53ms
memory: 6780kb
input:
3 100000 998244353 gbppzfsncqyzmuwrcvtxsciucxusskcjhaanwhqmyncytwhkubrvcqxgcehdxyewdyvpqjcmrnmlgrytrucexmmfulqbtfctehphmrzkosyvhtvjrromqncbgsjcwhmlqidkycaxyhsrduoxayntuhqubvboseeziwjvrfagsbvtxjjbexnajqapgxydwtztzbbdpoydnjipfizdfpmczgqvdmpvxbqubtygkfpdeonegfzsttirbhzkobbigwneyvtcxndfkljdvbbcfnadtfhgo...
output:
4 1649 3651
result:
ok 3 number(s): "4 1649 3651"
Extra Test:
score: 0
Extra Test Passed