Girls Love 233
Girls Love 233
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
As you see, luras sneaked into another girl's QQgroup to meet her indescribable aim.
However, luras can only speak like a cat. To hide her real identity, luras is very careful to each of her words.
She knows that many girls love saying "233",however she has already made her own word at first, so she needs to fix it.
Her words is a string of length n,and each character of the string is either '2' or '3'.
Luras has a very limited IQ which is only m.
She could swap two adjacent characters in each operation, which makes her losing 2 IQ.
Now
the question is, how many substring "233"s can she make in the string
while her IQ will not be lower than 0 after her operations?
for example, there is 1 "233" in "2333", there are 2 "233"s in "2332233", and there is no "233" in "232323".
and as for each case,
the first line are two integers n and m,which are the length of the string and the IQ of luras correspondingly.
the second line is a string which is the words luras wants to say.
It is guaranteed that——
1 <= T <= 1000
for 99% cases, 1 <= n <= 10, 0 <= m <= 20
for 100% cases, 1 <= n <= 100, 0<= m <= 100
there should be one integer in the line which represents the largest possible number of "233" of the string after her swap.
6 2
233323
6 1
233323
7 4
2223333
1
2
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
const int maxn=1e5+;
const int N=1e3+;
using namespace std;
ll gcd(ll p,ll q){return q==?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=;while(q){if(q&)f=f*p%mod;p=p*p%mod;q>>=;}return f;}
int n,m,k,t,dp[][][],pos[],cnt,cas,ret;
char a[];
int main()
{
int i,j;
scanf("%d",&cas);
while(cas--)
{
scanf("%d%d",&n,&m);
m/=;
ret=cnt=;
scanf("%s",a+);
for(i=;i<=n;i++)if(a[i]=='')pos[++cnt]=i;
pos[++cnt]=i;
memset(dp[],-,sizeof(dp[]));
dp[][][m]=;
for(i=;i<=cnt;i++)
{
for(j=i;j<=n+;j++)
{
for(k=;k<=m;k++)
{
dp[i][j][k]=-;
for(t=i-;t<j;t++)
{
if(k+abs(j-pos[i])<=m&&dp[i-][t][k+abs(j-pos[i])]!=-)
{
dp[i][j][k]=max(dp[i][j][k],dp[i-][t][k+abs(j-pos[i])]+(j-t>&&i>));
}
}
if(i==cnt&&j==n+&&ret<dp[i][j][k])ret=dp[i][j][k];
}
}
}
printf("%d\n",ret);
}
return ;
}
/*
1
5 19
33233
ans:1
*/
Girls Love 233的更多相关文章
- 【HDU 6017】 Girls Love 233 (DP)
Girls Love 233 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)To ...
- HDU 6017 Girls Love 233(多态继承DP)
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=6017 [题目大意] 给出一个只包含2和3的串,你可以花费两个智力值交换相邻的两个字符 问在智力值不 ...
- HDU_6017_Girls love 233_(dp)(记忆化搜索)
Girls Love 233 Accepts: 30 Submissions: 218 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
- [2018HN省队集训D6T2] girls
[2018HN省队集训D6T2] girls 题意 给定一张 \(n\) 个点 \(m\) 条边的无向图, 求选三个不同结点并使它们两两不邻接的所有方案的权值和 \(\bmod 2^{64}\) 的值 ...
- HDU - 3040 - Happy Girls
先上题目: Happy Girls Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- Android Weekly Notes Issue #233
Android Weekly Issue #233 November 27th, 2016 Android Weekly Issue #233 本期内容包括: 用Mockito做RxJava的单元测试 ...
- 2013成都网络赛 C We Love MOE Girls(水题)
We Love MOE Girls Time Limit: 1000/500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- 123——Appium Girls活动
有感于Ruby Girls和Python Girls,在15年就想组织一次移动测试的妹子活动,框架选择Appium, 从15年夏天开始准备,申请Google的会议室,招募教练,开放报名,审核报名,到正 ...
- HDU 5015 233 Matrix --矩阵快速幂
题意:给出矩阵的第0行(233,2333,23333,...)和第0列a1,a2,...an(n<=10,m<=10^9),给出式子: A[i][j] = A[i-1][j] + A[i] ...
随机推荐
- ES mapping可以修改include_in_all,也可以修改index_options,norm,但是无法修改_all属性!
ES mapping可以修改include_in_all,也可以修改index_options,norm,但是无法修改_all属性! curl -XPOST "http://localhos ...
- min-max容斥小结
https://www.zybuluo.com/ysner/note/1248287 定义 对于一个集合\(S\), \(\min(S)\)表示其第一个出现的元素(\(or\)最小的元素), \(\m ...
- shell脚本-基础
shell脚本-基础 编程基础 程序是指令+ 数据 程序编程风格: 过程式:以指令为中心,数据服务于指令 对象式:以数据为中心,指令服务于数据 shell 程序提供了编程能力,解释执行. 计算运行二进 ...
- Boost.Build特点(译)
Boost.Build Boost.Build makes it easy to build C++ projects, everywhere. Boost.Build让构建C++项目在任何地方都很容 ...
- Coursera公开课-Machine_learing:编程作业8(2016-10-06 20:49)
Anomaly Detection and Recommender Systems 本周编程作业分为两部分:异常检测和推荐系统. 异常检测:本质就是使用样本的到特种值的gaussian分布,来预估正确 ...
- 本地mongochef连接其他计算机上的数据库认证失败解决方法
关闭防火墙或者在信任程序列表添加运行目录下的mongod.exe即可
- MySQL索引----数据结构及算法原理
摘要 本文以MySQL数据库为研究对象,讨论与数据库索引相关的一些话题.特别需要说明的是,MySQL支持诸多存储引擎,而各种存储引擎对索引的支持也各不相同,因此MySQL数据库支持多种索引类型,如BT ...
- Android 获取android安装apk框的安装状态(如点击取消、返回)
最近鼓捣android,碰到个问题,因为没有root权限,需要调用Intent安装apk,但需要获取用户是否安装了(如,用户点击了返回或取消),查了很多文章,最后可以解决,但有瑕疵,解决方法如下: p ...
- 亚马逊EC2构建代理服务器心血历程
1.亚马逊上申请一台免费的EC2服务器,有相应的教程,绑定信用卡,预支付1美元,据说可以退回(防止到期后直接扣款,支付后通过修改卡信息,但好象有提示了,说卡不对了,也不管它了,到期后再说,美国人也不是 ...
- 基于证书的MS SQL2005数据库镜像搭建
一.准备工作: 3台服务器同版本,硬盘分区大小相同,安装相同版本数据库软件. host中分别标注3台服务器IP和主机名称. 主体服务器上创建数据库,并进行完整备份数据库和数据库事务. 拷贝备份文件给镜 ...