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] ...
随机推荐
- 使用JDBC处理MySQL大文本和大数据
LOB,Large Objects,是一种用于存储大对象的数据类型,一般LOB又分为BLOB与CLOB.BLOB通常用于存储二进制数据,比如图片.音频.视频等.CLOB通常用于存储大文本,比如小说. ...
- MSP430:中断简介
(5).中断应用程序举例(外部中断): void interrupt_initial() { P1DIR&=~BIT7; //P1.7为输入 P1IE|=0x80; //P ...
- 【转载】sql索引存储结构
一.引言 对数据库索引的关注从未淡出我的们的讨论,那么数据库索引是什么样的?聚集索引与非聚集索引有什么不同?希望本文对各位同仁有一定的帮助.有不少存疑的地方,诚心希望各位不吝赐教指正,共同进步.[最近 ...
- [App Store Connect帮助]三、管理 App 和版本(2.1)输入 App 信息:查看和编辑 App 信息
在您添加 App 至您的帐户后,您也可以在“我的 App”部分查看和编辑 App 信息和平台版本信息. 在输入 App 信息前,请检查必填项.可本地化和可编辑属性.您在上传构建版本或提交您的 App ...
- 点开瞅瞅,再来几道Python面试题吧,Python面试题No20
本面试题题库,由公号:非本科程序员 整理发布 第1题:如何理解 Django 被称为 MTV 模式? 这个题就是面向对象设计和设计模式的开始. 你可能比较熟悉的模式叫做: MVC.说是 Model V ...
- BZOJ 3625 多项式求逆+多项式开根
思路: RT //By SiriusRen #include <bits/stdc++.h> using namespace std; <<,mod=; int A[N],C[ ...
- 涨知识 --- VI
1.空类所占空间大小 空类所占空间为1,单一继承的空类空间也为1,多继承的空类空间还是1.但是虚继承涉及虚表(虚指针),所以sizeof(C)的大小为4. 2.内联函数与宏定义 Ans:内联函数和普通 ...
- 未能加载文件或程序集Microsoft.SharePoint.Sandbox.dll
项目引用了MiscroSoft.SharePoint.dll程序集,编译后页面报错: 未能加载文件或程序集“Microsoft.Sharepoint.Sandbox, Version=14.0.0.0 ...
- ansible 显示运行时间
#独家秘诀cd /etc/ansible mkdir callback_plugins cd callback_plugins wget https://raw.githubusercontent.c ...
- javascript特殊值常量
Infinity 表示无穷大的特殊值.当数字运算结果超出javascript能表示的数字范围时. Nan 特殊的非数字值(not a number).0除0.数字运算符的操作数为字符等情况. Numb ...