cf-div 872 div cf
Codeforces Round 618 (Div. 2)
# Codeforces Round 618 (Div. 2) https://codeforces.com/contest/1300 ## A. Non-zero 要求和,积都不为0,则先把全部0操作一次,然后再check 和是否为0,是的话再对任意数操作一次即可。 ```CC #include ......
CF938G Shortest Path Queries 题解
[TOC] # 题目链接 [CF938G](https://www.luogu.com.cn/problem/CF938G "CF938G") 洛谷挂了 只能交CF # 题目分析 本题有以下几个关键点: ## 为什么使用生成树建树 首先 根据 $WC2011$ 我们发现可以使用 $dfs$ 序来保存 ......
Codeforces Round 888 (Div. 3) A-F
## A. Escalator Conversations 题意:有一个扶梯,有n个人要站扶梯,这个扶梯有m个位置,第i个位置的高度为i*k,Vlad高H,第i个人高h[i],当且仅当两个人所处的位置高度加上自身身高刚好相同时才能谈话,问能和Vlad谈话的有多少人。 ### Solution 直接计 ......
CF309E解题报告
[题面](https://www.luogu.com.cn/problem/CF309E) ## 分析 求的是最大值最小,肯定容易想到二分,该题目的答案的单调性是存在的,因为如果你找到一组合法的解,可以将距离最大的两个区间的距离再增大,这样更大的答案一定是能得到的。 既然我们已经得到了二分的合理性, ......
CF1053E-Euler Tour题解
# 前言 还是一道神仙题 很难想 # 题面 luogu上copy的 样例解释懒得翻,我觉得应该都看得懂样例吧。 ## 题面翻译 现有一棵 $n$ 个点的形态未知的树,给定其长度为 $2n-1$ 的欧拉序的一部分 请根据给出的残缺的欧拉序还原出一个完整的欧拉序或判断不存在这样的树 输入中用非零数字表示 ......
CF1010F Tree
**题意**: - 给定一棵根为 $1$ 的二叉树 $T$,根上有 $x$ 个水果。 - 某些枝条(二叉树的边)会断掉,留下一个包含根节点的联通块 $T'$。 - 给剩下的 $T'$ 中每个点 $u$ 赋点权 $a_u$ 表示这个点上的水果数量,满足 $a_1=x$ 并且 $a_u\ge \sum\ ......
Codeforces Round #888 (Div. 3) A-G
[比赛链接](https://codeforces.com/contest/1851) # A ## 代码 ```c++ #include using namespace std; using ll = long long; bool solve() { int n, m, k, H; cin >> ......
Codeforces Round 888 (Div. 3) - D
[toc] Codeforces Round 888 (Div. 3) 赛后摘记 # [D. Prefix Permutation Sums](https://codeforces.com/contest/1851/problem/D) **题意** 判断给定的长为n - 1数组,是否为某个 1 ~ ......
Codeforces Round 888 (Div. 3)
# A. Escalator Conversations ```cpp #include using namespace std; #define int long long void solve(){ int n , m , k ,H; cin >> n >> m >> k >> H; vecto ......
CF1184A3 Heidi Learns Hashing (Hard)
令 $c_i={w_1}_i-{w_2}_i$,相当于找到 $(r,P)$,满足: $$\sum\limits_{i=0}^nc_ir^i\equiv 0 \pmod P$$ 把这个东西写成多项式形式,令 $f(x)=\sum\limits_{i=0}^nc_ix^i$,即找到一个 $(r,P)$, ......
43. CF-Walk the Runway
[Walk the Runway](https://codeforces.com/contest/1826/problem/E) 题意有点绕,在这里先简单解释一下: 有 $n$ 个人和 $m$ 个城市,每个人都有一个贡献值 $p_i$,每个人对每个城市有一个打分 $r_{i,j}$。现在需要选出 $ ......
[CF1601C] Optimal Insertion
# Optimal Insertion ## 题面翻译 ### 题目大意 给定两个序列 $a,b$,长度分别为 $n,m(1\leq n,m\leq 10^6)$。接下来将 $b$ 中的所有元素以**任意方式**插入序列 $a$ 中**任意位置**,请找出一种插入方式使结果序列中的逆序对数量最小化, ......
Codeforces Round 888 (Div. 3)
Codeforces Round 888 (Div. 3) A - Escalator Conversations 思路:求出每个人与Vlad的身高差d,若的能被k整除,且d/k<m则YES #include<bits/stdc++.h> using namespace std; #define i ......
Codeforces Round 888 (Div. 3)F(异或小技巧)
题意:给你一个数组长度为n的a数组,要求a数组的值为非负整数,再给你一个k,a的值全小于2的k次方,找到一个小于a的k次方的值x,再从a中找到两个值,让他们 (ai⊕x)&(aj⊕x)最小 结论:n个数的最小异或对的答案就是排序后最小的相邻异或和 思路:(ai⊕x)&(aj⊕x)的最高位为1,可以把 ......
【题解】Educational Codeforces Round 150(CF1841)
赛时过了 A-E,然后就开摆了,为什么感觉 C 那么无厘头[发怒][发怒] 排名:25th ## A.Game with Board ### 题目描述: Alice 和 Bob 玩游戏,他们有一块黑板。最初,有 $n$ 个整数 $1$。Alice 和 Bob 轮流操作,Alice 先手。 轮到时,玩 ......
CF1853C Ntarsis' Set
[Miku](https://codeforces.com/contest/1853/problem/C) 一道逆向思维的题目。 我们假设最后的最小的数是个1,放在第一个位置上,然后我们往数列开头按照规则插入0,其中应该插在这个1后面的,我们视为无效插入,插在这个1前面的,我们视为有效插入。 显然随 ......
CF1776M Parmigiana With Seafood 题解
先将所有的叶子取 $\max$ 贡献给答案,以下讨论的所有点中不考虑叶子。 首先可以考虑先手能否删到 $n$:不难发现当 $2 \mid n$ 的时候可以,然后我们就排除了一半的 $n$,于是以下令 $2 \not \mid n$。接下来,考虑先手能否删掉 $n-1$,那么把 $n-1 \to n$ ......
Codeforces Round 886 (Div. 4) D - H
D. Balanced Round
E. Cardboard for Pictures
F. We Were Both Children
G. The Morning Star
H. The Third Letter ......
Codeforces Round 887 (Div. 2) D.Imbalanced Arrays
Problem - D - Codeforces 题目规定了一种“平衡数组”,数组中的任意一个数绝对值小于等于n且不等于零,任意两个数的和不为0,给n个数a[i],分别表示位于i的数可以与a[i]个数(包括它自己)相加为正。 现在给出n和a数组,要求构造平衡数组,不能构造的话输出-1 我们不难得出以 ......
题解 CF1844G【Tree Weights】
## problem 一棵树边带正整数权,给出所有 $dis(i,i+1)$,还原树的边权,或者无解。$n\leq 10^5,V\leq 10^{12}$。 ## solution 首先很容易得到 $n$ 个方程形如 $dep_1=0,dep_i+dep_{i+1}-2dep_{lca(i,i+1) ......
题解 CF1601C【Optimal Insertion】
特别鸣谢: ## problem 两个数组 $a,b$ 长度分别为 $n,m$。将 $b$ 的所有元素以任意顺序插入 $a$ 的任意位置,使最终序列逆序对数量最小,并输出这个值。$n,m\leq 10^6$。 ## solution $b$ 明显是排序成不降的最优,$a$ 原来的逆序对个数无法改变, ......
Educational Codeforces Round 35 (Rated for Div. 2)
# Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 ## A. Nearest Minimums ```CC #include using namespace std; con ......
Educational Codeforces Round 71 (Rated for Div. 2)
Educational Codeforces Round 71 (Rated for Div. 2) A - There Are Two Types Of Burgers 思路:价格高的优先取 #include<bits/stdc++.h> using namespace std; #define ......
Codeforces Round 887 (Div. 2) A-D
# Codeforces Round 887 (Div. 2) ## A. Desorting 题意:给出一个数组,可以进行任意次以下操作: 选择一个i 对于数组中的a[1],a[2],...,a[i]全部+1 a[i+1]...a[n]全部-1, 问最小使得数组变得无序的操作是多少次 ### So ......
题解 CF1501B 【Napoleon Cake】
posted on 2021-03-16 17:42:06 | under 题解 | [source](https://www.luogu.com.cn/blog/_post/319814) 题目可以转化一下:给一个长为 $n$ 的数组 $a$,请求出一个长为 $n$ 的数组 $b$。要求若 $a_ ......
题解 CF1501A 【Alexey and Train】
posted on 2021-03-13 21:57:02 | under 题解 | [source](https://www.luogu.com.cn/blog/_post/319230) 简单模拟题,考验选手的读题能力~~和使用谷歌翻译的能力~~。 先定义一个 $now=0$,我们最后算出来的结 ......
题解 CF1497C1 【k-LCM (easy version)】
posted on 2021-03-20 08:26:53 | under 题解 | [source](https://www.luogu.com.cn/blog/_post/320621) 看数据范围,$1\leq T\leq10^4$,$1\leq n\leq 10^9$,显然是构造题。 我们分 ......
题解 CF1497C2 【k-LCM (hard version)】
posted on 2021-03-20 09:09:40 | under 题解 | [source](https://www.luogu.com.cn/blog/_post/320635) 2023 编者注:有一些链接点不进去,分别是 cf1497c1 的 cf 页面和 此题与 [CF1497C1 ......
【大联盟】20230714 T1 三分网络(tri) 题解 CF1666K 【Kingdom Partition】
## 题目描述 [here](https://codeforces.com/problemset/problem/1666/K)。 ## 题解 赛时得分:$30/30$,想了很久网络流最后不会。 感觉这题就纯纯对脑洞,因为把题目中的 $2$ 改成 $3$ 就做不了)))不过还是相当有意思的。 考虑如 ......