因为很懒,没有时间,只会口胡等等原因,所以有些题目就不打code了

$luogu:$


P1973 [NOI2011]Noi嘉年华

时间离散化,预处理一个区间$[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)$


P3188 [HNOI2007]梦幻岛宝珠

$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:$


hihocoder1954 : 压缩树 :

操作可离线,贡献可根据祖先递推。

dfs序+$multiset$维护动态虚树

插入新操作(节点)时,对与前驱后缀的$lca$分类讨论,取深度大的点。

该点与lca之间的这一段就是新加入的贡献。

unsolved question's solution的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 66. Regular Expression Matching

    Regular Expression Matching Implement regular expression matching with support for '.' and '*'. '.' ...

  4. 319. Bulb Switcher——本质:迭代观察,然后找规律

    There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every ...

  5. 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 ...

  6. Valid Parentheses

    Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the inpu ...

  7. leetcode Jump Game II python

    @link http://www.cnblogs.com/zuoyuan/p/3781953.htmlGiven an array of non-negative integers, you are ...

  8. leetcode Combination Sum II python

    Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in ...

  9. 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 ...

随机推荐

  1. TTTTTTTTTTTTTTTTT HDU 2586 How far away LCA的离线算法 Tarjan

    链接: How far away ? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  2. windows powershell的常用命令

    cmd开启3389 如何用CMD开启3389与查看3389端口 开启 REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Terminal /f 查端口 net ...

  3. spring cloud:config-eureka-refresh-bus-rabbitmq

    config-server-eureka-bus-rabbitmq 1. File-->new spring starter project 2.add dependency <paren ...

  4. java跨越请求实例

    使用Access-Control-Allow-Origin解决跨域 什么是跨域 当两个域具有相同的协议(如http), 相同的端口(如80),相同的host(如www.google.com),那么我们 ...

  5. shell命令别名

    ~/.bashrc文件 [root@linuxzgf ~]# vi ~/.bashrc            在alias cp='cp -i'前加上"#"注释,重新登录即可实现复 ...

  6. sh脚本获取当前目录

    #!/bin/bashcurDir=$(pwd)echo "cur dir is:$curDir"

  7. leetcode-mid-sorting and searching - 240. Search a 2D Matrix II -NO

    mycode   time limited def searchMatrix(matrix, target): def deal(data): if not data: return False ro ...

  8. 系统分析与设计HW1

    软件工程的定义 1993年,电气电子工程师学会(IEEE)给出了一个定义:"将系统化的.规范的.可度量的方法用于软件的开发.运行和维护的过程,即将工程化应用于软件开发中". 阅读经 ...

  9. 【Linux 应用编程】进程管理 - 进程间通信IPC之共享内存 mmap

    IPC(InterProcess Communication,进程间通信)是进程中的重要概念.Linux 进程之间常用的通信方式有: 文件:简单,低效,需要代码控制同步 管道:使用简单,默认阻塞 匿名 ...

  10. c# AES128 加解密算法

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...