unsolved question's solution
因为很懒,没有时间,只会口胡等等原因,所以有些题目就不打code了
$luogu:$
时间离散化,预处理一个区间$[l,r]$内的最多活动个数$in[l][r]$
无限制:
设$f[i][j]$表示到第$i$个时间点,第一个会场开$j$个活动时,第二个会场的最大活动数量
$f[i][j]=max(f[k][j-in[k][i]],f[k][j]+in[k][i])$
有限制:
把时间分成三段,上面的dp倒着跑一遍得出$g[i][j]$
枚举必须取区间$[l,r]$的最大贡献$h[l][r]$,再枚举左边取$x$个,右边取$y$个
$h[l][r]=min(x+in[l][r]+y,f[l][x]+g[r][y])$
注意到$x$递增时,$f[l][x]$递减。所以$g[r][y]$只能递增,即$y$必须递减,具有单调性
$y$用指针维护,复杂度降至$O(n^3)$
$a,b$很小,考虑对$b$分层后合并求解。
设$f[i][j]$表示代价为$a*b^i$的物品,占用$j*b^i$空间,跑01背包
合并时,$f[i][j]$表示代价为$a*b^{0 \sim i}$的物品,占用$j*b^i+(w$&$(2^i-1))$($w$二进制下的前$i-1$位)的空间
$f[i][j]=max(f[i][j],f[i][j-k]+f[i-1][min(s[i-1],k*2+(m$&$2^{i-1})])$,$s[i]$为前$i$层物品体积和$/2^i$
因为$j$倒序枚举,此时$f[i][j-k]$还是指占用$(j-k)*b^i$的空间
答案即为$f[m][1]$,$m$为$W$的二进制位数
$others:$
操作可离线,贡献可根据祖先递推。
dfs序+$multiset$维护动态虚树
插入新操作(节点)时,对与前驱后缀的$lca$分类讨论,取深度大的点。
该点与lca之间的这一段就是新加入的贡献。
unsolved question's solution的更多相关文章
- Convert a given Binary Tree to Doubly Linked List
The question and solution are from: http://www.geeksforgeeks.org/convert-given-binary-tree-doubly-li ...
- A trip through the Graphics Pipeline 2011_12 Tessellation
Welcome back! This time, we’ll look into what is perhaps the “poster boy” feature introduced with th ...
- 66. Regular Expression Matching
Regular Expression Matching Implement regular expression matching with support for '.' and '*'. '.' ...
- 319. Bulb Switcher——本质:迭代观察,然后找规律
There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every ...
- 318. Maximum Product of Word Lengths ——本质:英文单词中字符是否出现可以用26bit的整数表示
Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the tw ...
- Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the inpu ...
- leetcode Jump Game II python
@link http://www.cnblogs.com/zuoyuan/p/3781953.htmlGiven an array of non-negative integers, you are ...
- leetcode Combination Sum II python
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in ...
- Codeforces Round #440 (Div. 2, based on Technocup 2018 Elimination Round 2) D. Something with XOR Queries
地址:http://codeforces.com/contest/872/problem/D 题目: D. Something with XOR Queries time limit per test ...
随机推荐
- 解决JavaServer Faces 2.2 requires Dynamic Web Module 2.5 or newer问题
** 错误1: **在eclipse中新创建一个web项目的时候项目下的JSP文件中会爆出错误:The superclass “javax.servlet.http.HttpServlet” was ...
- Linux培训教程 浅谈:PHP在linux上执行外部命令(整理)
一.PHP中调用外部命令介绍 二.关于安全问题 三.关于超时问题 四.关于PHP运行linux环境中命令出现的问题 一.PHP中调用外部命令介绍 在PHP中调用外部命令,可以用,1>调用专门函数 ...
- [ZOJ3649]Social Net 题解
前言 这道题目珂以说是很毒瘤了. 题解 首先克鲁斯卡尔求最大生成树,输出边权和. 倍增维护四个值: 链上最大值/最小值 链向上/向下最大差值 当然祖先是肯定要维护的. 然后把一条链经LCA分成 ...
- 目标检测Object Detection概述(Tensorflow&Pytorch实现)
1999:SIFT 2001:Cascades 2003:Bag of Words 2005:HOG 2006:SPM/SURF/Region Covariance 2007:PASCAL VOC 2 ...
- Spring Boot教程(十九)RESTful API单元测试
下面针对该Controller编写测试用例验证正确性,具体如下.当然也可以通过浏览器插件等进行请求提交验证. @RunWith(SpringJUnit4ClassRunner.class) @Spri ...
- sqli-labs(32)
0x1查看源代码 (1)代码关键点 很明显,代码中利用正则匹配将 [ /,'," ]这些三个符号都过滤掉了 preg_replace 0x2 宽字符注入 (1)前言 在mysql中,用于转义 ...
- 一台linux机器远程mount另一台linux机器
本机电脑系统是unbantu,要将另一台linux电脑上的文件mount到本机目录下.mount的原理是网络文件系统,即NFS,本机操作步骤如下 一,安装 nfs-common : apt inst ...
- express中redirect传递数据
redirect中无法跟render一样传递数据 在index中,可以通过session重定向到login 在login.js 中获取req.session,渲染到login.ejs中,最后js获取
- js实现两个从input获取到的数字相加引发的问题
从input中获取到的数据是文本类型的,如果不转化类型直接相加会变成字符串的相加. 使用Number()函数可以解决这个问题,如下 var c = Number(a) + Number(b)
- 清北学堂2019.7.18 & 清北学堂2019.7.19
Day 6 钟皓曦 经典题目:石子合并 可以合并任意两堆,代价为数量的异或(^)和 f[s]把s的二进制所对应石子合并成一堆所花代价 枚举s的子集 #include<iostream> u ...