当前位置:网站首页>[8.3] Code Source - [meow ~ meow ~ meow~] [tree] [and]
[8.3] Code Source - [meow ~ meow ~ meow~] [tree] [and]
2022-08-05 04:01:00 【ZhgDgE】
#865. 喵 ~ 喵 ~ 喵~
题意:有 m ( 1 ≤ m ≤ 1 0 5 ) m(1\leq m\leq 10^5) m(1≤m≤105) 次操作,每次操作:如果 o p = 1 op=1 op=1 ,Is added in the weight set is an interval [ l , r ] ( 1 ≤ l ≤ r ≤ 1 0 5 ) [l,r](1\leq l\leq r\leq 10^5) [l,r](1≤l≤r≤105) ;如果 o p = 2 op=2 op=2 ,Is given a range [ l , r ] ( 1 ≤ l ≤ r ≤ 1 0 5 ) [l,r](1\leq l\leq r\leq 10^5) [l,r](1≤l≤r≤105) ,How many q collection and a given interval intersect.
思路:This problem has a more classic solution.假设当前有 m m m 个区间 ,给定区间 [ L , R ] [L,R] [L,R] ,The fellowship with the given interval of the interval number is :左端点在 R R R On the left side of the interval number 减去 右端点在 L L L On the left side of the interval number,即 ∑ i = 1 m [ l i ≤ R ] − ∑ i = 1 m [ r i < L ] \sum_{i=1}^m[l_i\leq R]-\sum_{i=1}^m[r_i<L] ∑i=1m[li≤R]−∑i=1m[ri<L] .Because the left endpoint in R R R 左边的区间,If you don't intersect with the given interval,Is necessarily right endpoints in L L L 左边.
Then how is open two tree array,一个维护 { l } \{l\} { l} 一个维护 { r } \{r\} { r} ,就可以了.
AC代码:http://oj.daimayuan.top/submission/317153
#154. 树
题意:有一棵 n ( 1 ≤ n ≤ 3000 ) n(1\leq n\leq 3000) n(1≤n≤3000) 个节点的以 1 1 1 为根的有根树.现在可以对这棵树进行若干次操作,每一次操作可以选择树上的一个点然后删掉这个点和它的儿子之间的所有边.
现在想要知道对于每一个 k ∈ [ 1 , n ] k∈[1,n] k∈[1,n] ,最少需要多少次操作才能让图中恰好存在 k k k 个联通块.
思路:Initial connecting piece number for 1 1 1 ,定义 s i z ( i ) siz(i) siz(i) 表示点 i i i How many sons,如果删去 i i i Son to the side of the connecting block number will increase s i z ( i ) siz(i) siz(i) .
那么问题就转化成了 01 背包问题:背包体积上限为 k ( k ∈ [ 1 , n ] ) k(k\in[1,n]) k(k∈[1,n]) ,每个物品只有一个,体积为 s i z ( i ) siz(i) siz(i) ,价值为 1 1 1 ,Asked to fill a backpack k k k A volume of the minimum value.
AC代码:http://oj.daimayuan.top/submission/317187
#155. 与
题意:给定 n , k ( 1 ≤ n , k ≤ 1 0 4 ) n,k(1\leq n, k\leq 10^4) n,k(1≤n,k≤104) .Calculate how many length of k k k 的数组 a 1 , a 2 , ⋯ , a k a_1,a_2,\cdots,a_k a1,a2,⋯,ak ,满足:
- ∑ i = 1 k a i = n , a i ≥ 0 ∑_{i=1}^ka_i=n,a_i≥0 ∑i=1kai=n,ai≥0 .
- 对于任意的 i = 1 , … , k − 1 i=1,…,k−1 i=1,…,k−1 有 a i AND a i + 1 = a i + 1 a_i ~\text{AND} ~a_{i+1}=a_{i+1} ai AND ai+1=ai+1 .其中 AND \text{AND} AND 是与操作.
输出答案对 1 0 9 + 7 10^9+7 109+7 取模的结果.
思路:Consider the binary on every,从 1 ∼ k 1\sim k 1∼k 必然是 1 , 1 , ⋯ , 1 , 0 , ⋯ , 0 , 0 1,1,\cdots,1,0,\cdots,0,0 1,1,⋯,1,0,⋯,0,0 ,That we defined from the perspective of binary,This state the number of less,Move faster.定义 d p ( b i t , j ) dp(bit,j) dp(bit,j) 表示前 0 ∼ b i t 0\sim bit 0∼bit These bits can be as 0 / 1 0/1 0/1 ,且 b i t ∼ inf bit\sim \inf bit∼inf 位上都为 0 0 0 ,且总和为 j j j 时的方案数 .那么我们枚举 b i t bit bit How many letters are there in the seat 1 1 1 ,转移方程就是 d p ( b i t , j ) = ∑ j − k × 2 b i t ≥ 0 d p ( b i t − 1 , j − k × 2 b i t ) dp(bit,j)=\sum_{j-k\times 2^{bit} \geq 0}dp(bit-1,j - k\times 2^{bit}) dp(bit,j)=∑j−k×2bit≥0dp(bit−1,j−k×2bit)
边栏推荐
- Detailed and comprehensive postman interface testing practical tutorial
- UE4 在游戏运行时更改变量 (通过鼠标滑轮来更改第一人称角色的最大行走速度)
- Confessing the era of digital transformation, Speed Cloud engraves a new starting point for value
- How to find all fields with empty data in sql
- The most comprehensive exam questions for software testing engineers in 2022
- 【背包九讲——01背包问题】
- Web3.0 Dapps - the road to the future financial world
- 【8.3】代码源 - 【喵 ~ 喵 ~ 喵~】【树】【与】
- [BJDCTF2020]EasySearch
- Swing有几种常用的事件处理方式?如何监听事件?
猜你喜欢

UE4 通过与其它Actor互动开门

iMedicalLIS listener (2)

不看后悔,appium自动化环境完美搭建

UE4 第一人称角色模板 添加蹲伏功能

How to discover a valuable GameFi?

Index Mysql in order to optimize paper 02 】 【 10 kinds of circumstances and the principle of failure

Mysql的redo log详解
![[BJDCTF2020]EasySearch](/img/60/464de3bcdda876171b9f61ad31bff1.png)
[BJDCTF2020]EasySearch
![[8.1] Code Source - [The Second Largest Number Sum] [Stone Game III] [Balanced Binary Tree]](/img/f3/0d92e22a424206241f4e1640f1bf6b.png)
[8.1] Code Source - [The Second Largest Number Sum] [Stone Game III] [Balanced Binary Tree]

JeeSite新建报表
随机推荐
[MRCTF2020]Ezpop(详解)
DNS被劫持如何处理?
bytebuffer 内部结构
新人如何入门和学习软件测试?
[8.1] Code Source - [The Second Largest Number Sum] [Stone Game III] [Balanced Binary Tree]
markdown如何换行——md文件
What is the difference between SAP ERP and ORACLE ERP?
Industry Status?Why do Internet companies prefer to spend 20k to recruit people rather than raise their salary to retain old employees~
Paparazzi: Surface Editing by way of Multi-View Image Processing
【测量学】速成汇总——摘录高数帮
第一次性能测试实践,有“亿”点点紧张
UE4 通过与其它Actor互动开门
Mysql's redo log detailed explanation
[SWPU2019]Web1
[TA-Frost Wolf_may-"Hundred Talents Project"] Graphics 4.3 Real-time Shadow Introduction
The test salary is so high?20K just graduated
Open-Falcon of operation and maintenance monitoring system
【8.1】代码源 - 【第二大数字和】【石子游戏 III】【平衡二叉树】
Redis key basic commands
阿里本地生活单季营收106亿,大文娱营收72亿,菜鸟营收121亿