codeforces country binary ralph

Codeforces 1458F - Range Diameter Sum

先考虑直径的一些求法:最普遍的想法肯定是从点集中任意一个点开始 DFS 找到距其最远的点,再一遍 DFS 找到距离你找到的那个点最远的点。但是放在这个题肯定是不太行的。因此考虑一种更常用的求法:**合并**。更直观地说:我们定义树上一个圆 $(x,r)$ 表示距离 $x$ 点 $\le r$ 的所有 ......
Codeforces Diameter 1458F Range 1458

Codeforces[CF1036B]Diagonal Walking v.2题解

# 题目大意 很明显,这道题就是求 k 步之内到达点 $(a,b)$ ,然后尽量走对角线,求能走对角线的最大值。 # 做题思路 首先明白一个事实,即一个对角线可以通过增加一步而抵达点不变,如图: ![image](https://img2023.cnblogs.com/blog/3175066/20 ......
题解 Codeforces Diagonal Walking 1036B

Mysql用户建立触发器报错You do not have the SUPER privilege and binary logging is enabled

分析原因:是log_bin_trust_function_creators值为off导致,因为Table中有Trigger,如果不创建Trigger,不会出现这样的错误信息,但Trigger必须创建临时解决办法:用root用户登录: mysql -u root -pmysql>set global ......
触发器 privilege enabled logging 用户

Codeforces Round 881 (Div. 3)

~~失踪人口回归~~ VP 打的 ### A. Sasha and Array Coloring ``` int n; int a[maxN]; void solve(){ n=rd(); fp(i,1,n) a[i]=rd(); sort(a+1,a+n+1); ll ans=0; for(int ......
Codeforces Round 881 Div

Codeforces 1648F - Two Avenues

为啥会有人觉得这是板子题啊/tuu 先对图边双连通分量缩个点,然后考虑对两条边分情况讨论: - 两个桥边,显然答案就是经过这两个桥的路径数量之和,排序取前两大的即可。 - 一个桥边加一个非桥边,答案是经过那个桥边的路径数量,显然桥边数量 $\ge 2$ 肯定不用考虑这种情况,桥边数量 $=1$ 另外 ......
Codeforces Avenues 1648F 1648 Two

Binary Tree Inorder Traversal

Given the root of a binary tree, return the inorder traversal of its nodes' values. Example 1: ``` Input: root = [1,null,2,3] Output: [1,3,2] ``` Exam ......
Traversal Inorder Binary Tree

系统断电后,MySQL重启失败:[ERROR] Binlog has bad magic number; It‘s not a binary log file that can be used by this version of MySQL

系统断电后,MySQL重启失败: [ERROR] Binlog has bad magic number; It‘s not a binary log file that can be used by this version of MySQL [ERROR] Can't init tc log [ ......
MySQL version Binlog binary number

CodeForces 605E Intergalaxy Trips 题解

## 题意 > 有一张 $n$ 个点的有向完全图,边 $i \to j$ 有 $p_{i,j}$ 的概率出现($p_{i,i}=1$)。你要从 $1$ 开始,每天可以走一条出边或留在原地,求最优策略下走到 $n$ 的期望天数。输出小数(不取模)。 > $n \le 10^3$ ## 思路 设 $f( ......
题解 Intergalaxy CodeForces Trips 605E

Codeforces 1787H - Codeforces Scoreboard(平衡树优化 dp)

令 $c_i=b_i-a_i$,等价于我们钦定一个排列 $p$,最小化 $\sum \min(p_ik_i,c_i)$,拿 $\sum b_i$ 减去之就是答案。 我们钦定一些 $i$ 满足 $p_ik_iY.k;} }a[MAXN+5]; struct node{int ch[2],siz,key ......
Codeforces Scoreboard 1787H 1787

Educational Codeforces Round 150 (Rated for Div. 2) A-E

[比赛链接](https://codeforces.com/contest/1841) # A ## 代码 ```c++ #include using namespace std; using ll = long long; bool solve() { int n; cin >> n; if (n ......
Educational Codeforces Round Rated 150

[数据结构]Binary Indexed Trees(树状数组)

# Binary Indexed Trees(树状数组) ## 1.lowbit **lowbit(x)**是x的二进制表达式中最低位的1所对应的值。比如,6的二进制是110,所以lowbit(6)=2。 **lowbit(x) = x&(-x)** ## 2.定义,查询,修改(eg1) $a1,a ......
数据结构 数组 Indexed 结构 数据

CodeForces 1842E Tenzing and Triangle

[洛谷传送门](https://www.luogu.com.cn/problem/CF1842E "洛谷传送门") [CF 传送门](https://codeforces.com/contest/1842/problem/E "CF 传送门") 一个很显然的观察:选择的三角形两两重叠面积为 $0$, ......
CodeForces Triangle Tenzing 1842E 1842

CodeForces 1842G Tenzing and Random Operations

[洛谷传送门](https://www.luogu.com.cn/problem/CF1842G "洛谷传送门") [CF 传送门](https://codeforces.com/contest/1842/problem/G "CF 传送门") 原来还不会这种拆期望的套路![](//图.tk/0) ......
CodeForces Operations Tenzing Random 1842G

CodeForces 1842F Tenzing and Tree

[洛谷传送门](https://www.luogu.com.cn/problem/CF1842F "洛谷传送门") [CF 传送门](https://codeforces.com/contest/1842/problem/F "CF 传送门") 事实上自己方向一直是错的…… 绝对值不好弄,我一开始的 ......
CodeForces Tenzing 1842F 1842 Tree

Codeforces Round 875 (Div. 2) C. Copil Copac Draws Trees

bfs解法 如果是暴力求解的话就每次都扫描一次所有边直到所有点都和树连接 优化:每次扫描我们可以发现会重复扫描那些已经存在树中的边了,因此我们可以只扫描还没有存在树中的边且是没扫过的边 对于每次更新,比如由点a已经在树中,更新点b,我们只需判断点a被更新到树中点的编号和a-b边的编号的大小,如果比它 ......
Codeforces Round Copil Copac Draws

Codeforces Round #879 (Div. 2) A-E

[比赛链接](https://codeforces.com/contest/1834) # A ## 代码 ```c++ #include using namespace std; using ll = long long; bool solve() { int n; cin >> n; int c ......
Codeforces Round 879 A-E Div

B. Reverse Binary Strings

You are given a string $s$ of even length $n$. String $s$ is binary, in other words, consists only of 0's and 1's. String $s$ has exactly $\frac{n}{2} ......
Reverse Strings Binary

Codeforces Round 781 (Div. 2) E. MinimizOR (可持久化字典树)

[传送门](https://codeforces.com/contest/1665/problem/E) 题目大意: ** T组测试数据每组测试数据先输入一个n表示有一个长度为n的一维数组,然后输入n个数字表示这个一维数组。紧接着输入一个k表示有k个询问,对于每个询问会输入一个l和一个r表示询问数组 ......
字典 Codeforces MinimizOR Round 781

Codeforces Round 881 (Div

## E. Tracking Segments >给定初始长度为`n`,且全为`0`的序列`a`,然后给出`m`个线段,如果一个线段中`1`的个数严格大于`0`的个数,那么该线段称为一个漂亮线段,现在给出`q`次操作,每次操作使得序列`a`中位置`x`上的`0`变为`1`,请你求出第一次使得所有线段 ......
Codeforces Round 881 Div

Codeforces 1603D. Artistic Partition

题目链接:[D - Artistic Partition](https://codeforces.com/contest/1603/problem/D "D - Artistic Partition") 题目大意:要求将 $[1,n]$ 分成 $k$ 段,使得每段对应的 $c(l,r)$ 之和最小, ......
Codeforces Partition Artistic 1603

Codeforces Round 877 (Div. 2)A-D

Codeforces Round 877 (Div. 2)A-D A: 有负数就输出,没有就输出最大值即可。 void solve(){ int n; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; } sort(a+1,a+1+n); if(a[1]<0){ c ......
Codeforces Round 877 A-D Div

Codeforces Round 766 (Div. 2) 比赛报告

## 0 比赛经过 比赛还没开始的时候就感觉状态不太好。果然。 总归到底都是一个心态问题。 ### A 题经过 看 A 题,结果**半天看不懂,一开始没有注意到一定要在黑格子上操作**。扔到 DeepL 上翻译了一下,再手玩一下样例就做出来了,速度有点慢。CF 怎么这么喜欢出分讨题啊。 看题目不能太 ......
Codeforces 报告 Round 766 Div

Codeforces Round 881 (Div. 3)--F2

F2. Omsk Metro (hard version) #include<bits/stdc++.h> using namespace std; typedef long long ll; #define endl "\n" #define int long long const int N=2 ......
Codeforces Round 881 Div F2

Codeforces 1835F - Good Graph

good problem,bad round。 判断 YES 还是 NO 很trivial,就直接跑最大匹配看看是不是 $n$ 即可。 如果是 NO,那么考虑 Hall 定理的证明过程构造即可。具体方法就是找到左部任意一非匹配点,在残量网络上 BFS 可以到达的点,那所有可以到达的左部点形成的集合就 ......
Codeforces 1835F Graph 1835 Good

Codeforces 1835E - Old Mobile

首先先观察到一个非常浅显的性质:就是一个位置在序列中不是第一次出现,那么到这个位置的时候打出这个字符需要恰好一次按键,这是因为我们肯定在打出第一次出现这个字符的位置的时候已经知道哪个键对应这个字符了,到那个位置的时候直接敲一下就 ok 了。 也就是我们只用关心这个序列中出现了多少种不同的数,设为 $ ......
Codeforces Mobile 1835E 1835 Old

Codeforces Round 878 (Div. 3) D. Wooden Toy Festival

题目翻译:给定一个序列,你可以把序列分为任意的三组不要求顺序,对于每一组序列给出一个数字作为标准,求出序列中和该数字的差绝对值的最大值,现在要求你选顶三个数字使得三个序列的差最大值的最大值最小 解题思路:二分,要想方差最小,就让每一组的极差都最小,即最大值减最小值最小 #include <iostr ......
Codeforces Festival Wooden Round 878

Codeforces Round 881 (Div. 3) F2. Omsk Metro (hard version) (线段树 )

[传送门](https://codeforces.com/contest/1843/problem/F2) 大致题意: ** 动态给定一颗树,树上每个结点的权值一定为1或者-1。最开始有1号点,权值为1。** ** 输入n表示有n个操作,当第一个符号为+ a b表示添加结点操作,编号依次递增。a表示 ......
线段 Codeforces version Round Metro

Codeforces Round 881 (Div. 3)

## [A - Sasha and Array Coloring (CF1843 A)](https://codeforces.com/contest/1843/problem/A) ### 题目大意 给定一个数组,给每个元素涂色。求最大的代价。 代价为每个颜色的代价和。 每个颜色的代价为涂了该颜色 ......
Codeforces Round 881 Div

练习记录-cf-Codeforces Round 881 (Div. 3)A-F1

E是补的 太蠢了没想到 期末考完的复健 A. Sasha and Array Coloring 题意:可以给不同数字涂上很多颜色,每个颜色的贡献是同一个颜色内的数字最大值和最小值的差 思路:排序一遍,取头和尾的差 #include<bits/stdc++.h> #define close std:: ......
cf-Codeforces Codeforces Round 881 A-F

Codeforces Round 881 (Div. 3)

Codeforces Round 881 (Div. 3) A: void solve(){ int n; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; } sort(a+1,a+1+n); int ans=0; int l=1; int r=n; for(in ......
Codeforces Round 881 Div