1830d tree mex cf

9.6 CF1830 题解

# 9.6 CF1830 题解 ## A. Copil Copac Draws Trees [链接](https://www.luogu.com.cn/problem/CF1830A) 真弱智题不用讲 ## B. The BOSS Can Count Pairs ### 题意 每组数据给你一个 $n ......
题解 1830 9.6 CF

CF665F

[题目链接](https://codeforces.com/problemset/problem/665/F) ## description 给定 $n\leq 10^{11}$ 求 1 到 $n$ 中恰有 4 个因数的数的个数。 ## solution 这个数据范围容易想到筛子。 题目相当于让求 ......
665F 665 CF

CF1036F

[题目链接](https://codeforces.com/problemset/problem/1036/F) ## description $10^5$ 次询问 每次给定 $n\leq 10^{18}$, 求 2 到 $n$ 内质因子分解结果为 $p_{a_1}^{b_1}p_{a_2}^{b_ ......
1036F 1036 CF

CF1174E

[题目链接](https://codeforces.com/problemset/problem/1174/E) ## description 给定 $n\leq 10^6$, 求有多少个 $1$ 到 $n$ 的排列,对于一个 1 到 $n$ 的排列 $p$,$f(p)$ 表示 $p$ 的任意前缀内 ......
1174E 1174 CF

CF1852C Ina of the Mountain

*2400 https://codeforces.com/problemset/problem/1852/C 如果没有 $\mod k$ 的限制的话,我们都会做,因为都是正数,那么 $\sum_i^n d_i>0$,因此,答案即为 $\sum[d_i>0]d_i$。 但是现在多了一个操作,即为区间加 ......
Mountain 1852C 1852 Ina the

【题解】CF2600DP 选练(23.9.5-23.9.6)

低情商:感觉是比较套路的 高情商:十分 educational!!! ## CF258D Little Elephant and Broken Sorting ### 题目描述: 有一个 $[1,n]$ 的排列 $a$,会进行 $m$ 次操作,操作为交换 $(a_i,a_j)$。每次操作都有 $50 ......
题解 2600 23 CF DP

CF626F Group Projects

发现直接做非常困难,考虑将能力值排序后从小到大插入。 令 $f_{i,j,l}$ 表示前 $i$ 个人,有 $j$ 组需要继续加人,不和谐度之和**恰好**为 $l$ 的方案数。此时加入一个人对不和谐度之和产生的贡献为 $t=j\times(a_{i+1}-a_i)$。分三种情况转移: - 组数加一 ......
Projects Group 626F 626 CF

数据结构维护 mex 总结

## [P4137](https://www.luogu.com.cn/problem/P4137) ### solution 1: 我最初做这题是莫队,这是一道练习莫队+值域分块的好题。 莫队的时候记录两个东西,$b_i$ 表示 $i$ 在当前出现的次数,$c_i$ 表示值域第 $i$ 块中**有 ......
数据结构 结构 数据 mex

LCM Sum (CF E ) (正男则反, 二维数点/二维偏序, 大胆的抽象化简数学式子, 打表找规律)

思路: CF1712 E1/E2 LCM Sum (easy/hard version) 二维数点/二维偏序: 二维前缀和+扫描线+树状数组+ 离线处理 应用: 求 Q次询问, L-R内 x-y的 点的数量(矩形内点的数量) 直接用二维前缀和, 时间复杂度, 一定不允许, 发现 二维前缀和是由 4个 ......
偏序 式子 规律 数学 LCM

CF724G Xor-matic Number of the Graph

[题目链接](https://codeforces.com/problemset/problem/724/G) 不妨先看一道更为基础的题:[CF845G](https://codeforces.com/problemset/problem/845/G)以及[它的题解](https://www.cnb ......
Xor-matic Number Graph matic 724G

CF444C DZY Loves Colors

## [$DZY$ $Loves$ $Colors$](https://codeforces.com/problemset/problem/444/C) ### 一、题面翻译 有一个 $n$ 个元素组成的序列,每个元素有两个属性:颜色 $c_i$ 和权值$w_i$。$c_i$ 初始为$i$,$w_i ......
Colors Loves 444C 444 DZY

CF1860D 题解

在 Codeforces 上看到了这题的 $\mathcal{O}(n ^ 4 / \omega)$ 做法,和大家分享一下。 [原版 Solution 链接](https://codeforces.com/blog/entry/119504?#comment-1060285) 记 $d$ 为原字符串 ......
题解 1860D 1860 CF

【题解】CF1852D Miriany and Matchstick

考虑 `dp`,设 $f_{i,0/1}$ 表示考虑到前 $i$ 位,且第 $i$ 位填入 A/B 可能的答案集合,显然地朴素转移时间复杂度 $O(n^2)$。 试分析 `dp` 性质,观察发现所有 `dp` 中得到的集合为区间内抠去至多一个点。 > > 证明 > 我们首先来观察转移过程是怎样的。第 ......
题解 Matchstick Miriany 1852D 1852

Codeforces Round 858 (Div. 2) B. Mex Master

给一个长为 $n$ 的数组 $a$ ,定义 $a$ 的 $score$ 为 $a_1+ a_2, a_2 + a_3, \cdots, a_{n - 1} + a_n$ 的 $MEX$ 。 找到 $a$ 的 最小 $score$ 如果 $a$ 可以被重排。$(0 \leq a_i \leq 2 \t ......
Codeforces Master Round 858 Div

【题解】CF1852C Ina of the Mountain

我们先从题目的一部分入手。 如果说,我们没有当一个数为 $0$ 时,让这个数变成 $k$ 的性质,我们如何求答案呢? 很简单,在图上就是: 绿色线段的长度加起来即为答案(本图中是 $6$) 我们考虑很显然地,将一个数从 $0$ 变为 $k$ 即为将一个数一开始加上 $k$ 我们如果要让第 $i$ 列 ......
题解 Mountain 1852C 1852 Ina

CF1695D2 Tree Queries (Hard Version)

[原题](https://codeforces.com/problemset/problem/1695/D2) [翻译](https://www.luogu.com.cn/problem/CF1695D2) $$ \large{\color{#ff0000}{\text{被xjk搏杀了,wtcl}} ......
Queries Version 1695D 1695 Tree

CF845G Shortest Path Problem?

[原题链接](https://codeforces.com/problemset/problem/845/G) 不妨先了解几个前置知识/引理: 异或的抵消性质: * $a\oplus a=0$ * $\forall b[b\not= a],a\oplus b\not=0$ * $(a\oplus b ......
Shortest Problem 845G Path 845

【题解】CF1852B Imbalanced Arrays

我们假设当前出长度为 $len$,那么我们在序列中一定有一个 $len/0$,因为一定有一个绝对值最大的数,如果这个数是正数在原序列中就是 $len$,是负数在原序列中即为 $0$。 由上文,我们可以得到,一定不能有 $len$ 和 $0$ 同时出现的情况,也一定不能有 $len$ 和 $now$ ......
题解 Imbalanced Arrays 1852B 1852

树形结构el-tree选中子类时候,获取当前子类和所有上级父类id

选中子类时候,获取当前子类和所有上级父类id <el-tree :data="permissionsData" show-checkbox node-key="id" ref="tree" highlight-current :default-checked-keys=defaultPermissi ......
子类 树形 上级 el-tree 时候

【题解】Educational Codeforces Round 145(CF1809)

## A.Garland ### 题目描述: 有 $4$ 只灯泡,第 $i$ 只灯泡的颜色为 $s_i$ 。 一开始,所有灯泡都是关着的,你需要把它们都打开。你可以进行数次操作,每次操作改变一个灯泡的状态,即打开原本关着的灯泡或关上原本亮着的灯泡。第一次操作可选择任何灯泡,此后每一次被操作的灯泡的颜 ......
题解 Educational Codeforces Round 1809

[CF1768F]Wonderful Jump

[Wonderful Jump](https://www.luogu.com.cn/problem/CF1768F) 题目看错了,以为能往回跳...... 暴力转移式 $$ dp_i=min(dp_i,dp_j+\min_{k=j}^ia_k\times(i-j)^2) $$ 你会发现这个没啥单调性 ......
Wonderful 1768F 1768 Jump CF

CF1854 题解

# CF1854 题解 ### A 首先考虑只有非负的情况,次数完全可以接受 $19$ 次,所以直接用 $19$ 次做一次前缀和就可以保证单调不降了。 现在有了负数,考虑将负数变成正数,选出正数当中的最大值,然后用 $a_i + a_i \to a_i$ 这样自增的方式让它的绝对值大于负数最大值,因 ......
题解 1854 CF

error: The following untracked working tree files would be overwritten by merge

错误内容如下: error: The following untracked working tree files would be overwritten by merge: xxx/xxx/xxx/xxx/xxx/xxx/xxx.java Please move or remove them b ......

CF1852 题解

# CF1852 题解 ## A Ntarsis' Set ### 题意 有一个集合,初始状态里面有数字 $1$、$2$、$3$、$4$、$5$、......、$10^{1000}$。 现在给你一个长度为 $n$ 数组 $a (1\leq a_i \leq 10^9 )$,要进行 $k$ 次操作,每 ......
题解 1852 CF

【题解】CF1852A Ntarsis' Set

考虑我们先手模一下样例: $$ \begin{cases} 1&3&5&6&7\\ 2&8&10&11&12\\ 4&13&15&16&17 \end{cases} $$ ???一脸疑惑,有什么规律吗?真有,但是很难看出来捏。 正难则反,我们考虑如果知道操作一次后一个数的位置,我们可以很容易推出,操 ......
题解 Ntarsis 1852A 1852 Set

[CF1641D] Two Arrays

## 题目描述 Sam changed his school and on the first biology lesson he got a very interesting task about genes. You are given $ n $ arrays, the $ i $ -th o ......
Arrays 1641D 1641 Two CF

[CF1830E] Bully Sort

## 题目描述 On a permutation $ p $ of length $ n $ , we define a bully swap as follows: - Let $ i $ be the index of the largest element $ p_i $ such that ......
1830E Bully 1830 Sort CF

Minimum Edge Weight Equilibrium Queries in a Tree

Minimum Edge Weight Equilibrium Queries in a Tree There is an undirected tree with n nodes labeled from 0 to n - 1. You are given the integer n and a ......
Equilibrium Minimum Queries Weight Edge

[CF1599A] Weights

## 题目描述 You are given an array $ A $ of length $ N $ weights of masses $ A_1 $ , $ A_2 $ ... $ A_N $ . No two weights have the same mass. You can put ......
Weights 1599A 1599 CF

[CF1830D] Mex Tree

## 题目描述 You are given a tree with $ n $ nodes. For each node, you either color it in $ 0 $ or $ 1 $ . The value of a path $ (u,v) $ is equal to the ME ......
1830D 1830 Tree Mex CF