C. An impassioned circulation of affection                                                                time limit per test  2 seconds                                                          …
http://codeforces.com/contest/814/problem/C 12ooyomioomioo21 o2 o 这题我是用dp解的,不过好像很慢,比赛的时候算了下不会mle,就没滚动数组了. dp[i][k][ch]表示以第i位结尾,允许变化k次,所求的字符是ch时的最大连续数量. 如果k > 0,那么dp[i][k][ch] > 0的,因为肯定可以把第i位变了. 那么对于第i位来说,如果str[i]和ch相同,那么应该是dp[i][k][ch] = dp[i - 1][k…
//yy:因为这题多组数据,DP预处理存储状态比每次尺取快多了,但是我更喜欢这个尺取的思想. 题目链接:codeforces 814 C. An impassioned circulation of affection 题意:给出字符串长度n (1 ≤ n ≤ 1 500),字符串s由小写字母组成,q个询问q (1 ≤ q ≤ 200 000),每个询问为:mi (1 ≤ mi ≤ n)   ci ,表示可以把任意mi个字母改成ci,求每次改变后只由ci组成的最长连续字串的长度. 解法一:尺取法…
An impassioned circulation of affection time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Nadeko's birthday is approaching! As she decorated the room for the party, a long garland of Dianthu…
C. An impassioned circulation of affection time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Nadeko's birthday is approaching! As she decorated the room for the party, a long garland of Dian…
http://codeforces.com/contest/814/problem/C [题意] 给定一个长度为n的字符串s,一共有q个查询,每个查询给出一个数字m和一个字符ch,你的操作是可以改变字符串中的某些字母,最多改变m个,问操作后只包含字符ch的连续子序列最长是多少? [思路] 方法一: 有这么一类问题,需要在给的一组数据中找到不大于某一个上限的“最优连续子序列” 于是就有了这样一种方法,找这个子序列的过程很像毛毛虫爬行方式比较流行的叫法是“尺取法”. 有关尺取的练习: http://…
题目链接:http://codeforces.com/contest/814/problem/C 题意:给出一串字符串然后q个询问,问替换掉将m个字符替换为字符c,能得到的最长的连续的字符c是多长 题解:预处理dp[i][j]表示第i种字幕添加j个最长的连续为多长.然后与处理一下sum[j]表示前j个里有几个不是第i种字母的. 然后for一遍二分一下.更新dp. #include <iostream> #include <cstring> #include <vector&g…
题目链接:http://codeforces.com/contest/814/problem/C 题目: 题意:给你一个长度为n的字符串,m次查询,每次查询:最多进行k步修改,求字符c(要输入的字符)最长连续的长度. 思路:尺取法,预处理出每个字符连续长度为k需要的代价,然后O1查询. 代码实现如下: #include <set> #include <map> #include <queue> #include <stack> #include <cm…
思路: 对于题目中的一个查询(m, c),枚举子区间[l, r](0 <= l <= r < n),若该区间满足其中的非c字符个数x不超过m,则可以将其合法转换为一个长度为r-l+1的全c子序列,可以使用动态规划以O(n2)的复杂度计算,然而O(n2q)的复杂度还是太高了.于是先离线把26n中情况都计算出来,再打表即可.复杂度O(26n2+q). 实现: #include <iostream> #include <cstdio> using namespace s…
原题链接:http://codeforces.com/contest/814/problem/C 题意:有长度为n的一个字符串,q个询问,每个询问由数字m和字符c组成,问最多在字符串中替换m个字符,使连续的字符c的长度最大,输出这个最大值. 思路:首先可以想到,替换两段分开的子串变成连续的字符c肯定不能得到最大值,所以替换的部分必须是连续的一个子串.那么我们可以对于a-z每个字符枚举字符区间[l,r],区间内可被替换的字符数m对应能得到r-l+1的连续字符长度,一边枚举一边更新最大值.这里我们要…
A An abandoned sentiment from past 水题 #include<bits/stdc++.h> using namespace std; int a[300],b[300],n,k; bool cmp(int a,int b) { return a>b; } int main() {//freopen("t.txt","r",stdin); scanf("%d%d",&n,&k); f…
C. An impassioned circulation of affection time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Nadeko's birthday is approaching! As she decorated the room for the party, a long garland of Dian…
终判才知道自己失了智.本场据说是chinese专场,可是请允许我吐槽一下题意! A. An abandoned sentiment from past shabi贪心手残for循环边界写错了竟然还过了初判.回宿舍想想发现只要k大于1,可以直接输出Yes的. const int N=1e6+5; int a[N],b[N]; //char s[N]; int cmp(int a,int b) { return a>b; } int main() { int n,k; while(~scanf(&quo…
Description Harry: "But Hagrid. How am I going to pay for all of this? I haven't any money." Hagrid: "Well there's your money, Harry! Gringotts, the wizard bank! Ain't no safer place. Not one. Except perhaps Hogwarts." ― Rubeus Hagrid…
1911: [Apio2010]特别行动队 Time Limit: 4 Sec  Memory Limit: 64 MBSubmit: 4142  Solved: 1964[Submit][Status][Discuss] Description Input Output Sample Input 4 -1 10 -20 2 2 3 4 Sample Output 9 HINT f[i]=max{f[j]+...} 随便一化就好了 (a*(s[k]*s[k]-s[j]*s[j])+f[k]-f[…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4800 Problem Description A role-playing game (RPG and sometimes roleplaying game) is a game in which players assume the roles of characters in a fictional setting. Players take responsibility for acting…
1  升级说明 AEAI DP 3.7版本是AEAI DP一个里程碑版本,基于JDK1.7开发,在本版本中新增支持Rest服务开发机制(默认支持WebService服务开发机制),且支持WS服务.RS服务的热部署机制. 后续基于AEAI DP开发的开源AEAI应用软件,如:CRM.HR.WM.EM将会陆续基于AEAI DP 3.7版本进行升级. 2  升级内容 1.类库升级: a) 升级JDK1.7.X b) 升级CXF版本为3.1.2 c) 升级Spring版本为4.1.6.RELEASE d…
AEAI DP综合应用开发平台是一款扩展开发工具,专门用于开发MIS类的Java Web应用,本次发版的AEAI DP_v3.6.0版本为AEAI DP _v3.5.0版本的升级版本,该产品现已开源并上传至开源社区,下载地址:http://pan.baidu.com/s/1gdKlQvD. 1 升级说明 AEAI DP v3.6版本是一次常规升级,也是AEAI DP最后一次支持JDK1.6版本,后续AEAI DP产品升级将会基于JDK1.7进行扩展开发.AEAI DP 3.7版本将扩展支持Res…
1597: [Usaco2008 Mar]土地购买 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 4026  Solved: 1473[Submit][Status][Discuss] Description 农夫John准备扩大他的农场,他正在考虑N (1 <= N <= 50,000) 块长方形的土地. 每块土地的长宽满足(1 <= 宽 <= 1,000,000; 1 <= 长 <= 1,000,000). 每块土地…
参考资料: 1.元旦集训的课件已经很好了 http://files.cnblogs.com/files/candy99/dp.pdf 2.http://www.cnblogs.com/MashiroSky/p/6009685.html [一] 对于一类转移方程: f[i]=max{a[i]*b[j]+c[i]+d[j]} a[i]和c[i]是开始求解前就知道常数,b[j]和d[j]知道f[j]后就知道有关 可以使用斜率优化(不是这个形式就尽量往这个形式化) {以下讨论不严格区分优于和不差于} […
1010: [HNOI2008]玩具装箱toy Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 9812  Solved: 3978[Submit][Status][Discuss] Description P教授要去看奥运,但是他舍不下他的玩具,于是他决定把所有的玩具运到北京.他使用自己的压缩器进行压缩,其可以将任意物品变成一堆,再放到一种特殊的一维容器中.P教授有编号为1...N的N件玩具,第i件玩具经过压缩后变成一维长度为Ci.为了方便整理,P…
DP 这个是最常用但也最难理解的尺寸单位.它与“像素密度”密切相关,所以 首先我们解释一下什么是像素密度.假设有一部手机,屏幕的物理尺寸为1.5英寸x2英寸,屏幕分辨率为240x320,则我们可以计算出在这部手机的屏幕上, 每英寸包含的像素点的数量为240/1.5=160dpi(横向)或320/2=160dpi(纵向),160dpi就是这部手机的像素密度,像素密度的单位dpi是Dots Per Inch的缩写,即每英寸像素数量. 横向和纵向的这个值都是相同的,原因是大部分手机屏幕使用正方形的像素…
/** * 根据手机的分辨率从 dp 的单位 转成为 px(像素) */ public int dipTopx(Context context, float dpValue) { final float scale = context.getResources().getDisplayMetrics().density; return (int) (dpValue * scale + 0.5f); } /** * 根据手机的分辨率从 px(像素) 的单位 转成为 dp */ public int…
Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Description Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He wants to grow some yumm…
1225. Flags Time limit: 1.0 secondMemory limit: 64 MB On the Day of the Flag of Russia a shop-owner decided to decorate the show-window of his shop with textile stripes of white, blue and red colors. He wants to satisfy the following conditions: Stri…
题目链接: C. Subsequences time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is…
1030: [JSOI2007]文本生成器 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 3953  Solved: 1614[Submit][Status][Discuss] Description JSOI交给队员ZYX一个任务,编制一个称之为“文本生成器”的电脑软件:该软件的使用者是一些低幼人群,他们现在使用的是GW文本生成器v6版.该软件可以随机生成一些文章―――总是生成一篇长度固定且完全随机的文章—— 也就是说,生成的文章中每个字节都是完…
1087: [SCOI2005]互不侵犯King Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 3336  Solved: 1936[Submit][Status][Discuss] Description 在N×N的棋盘里面放K个国王,使他们互不攻击,共有多少种摆放方案.国王能攻击到它上下左右,以及左上左下右上右下八个方向上附近的各一个格子,共8个格子. Input 只有一行,包含两个数N,K ( 1 <=N <=9, 0 <= K &…
从低端向上,每个结点取下一层左右结点最大值和本身价值相加,dp[0][0]为最后结果 #include<iostream> #include<algorithm> #include<cstdio> using namespace std; #define MAXN 510 typedef long long LL; LL a[MAXN][MAXN],dp[MAXN][MAXN]; LL sum = ,level; int main() { int i,j; scanf(…
Network Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4478   Accepted: 1292 Description Yixght is a manager of the company called SzqNetwork(SN). Now she's very worried because she has just received a bad news which denotes that DxtNet…