codeforces distance minimum maximum

Educational Codeforces Round 149 (Rated for Div. 2) 题解

https://codeforces.com/contest/1837 https://codeforces.com/contest/1837/problems 利益相关:上紫祭。 真的不要以为这道题放在 F 就不敢做。 压线过题的感觉真好。 ![image](https://img2023.cnb ......
题解 Educational Codeforces Round Rated

Educational Codeforces Round 149 (Rated for Div. 2)

# Preface 补题,本来这场想现场打的,但是玩**《Island》**玩的有点上头就没打了~~(逸一时,误一世~~ 然后今天发现2h30min就没啥难度的全写了,早知道昨天现场打给大号涨波分了 不过现场打以我的尿性也不知道会整出什么逆天操作,等下一个细节写挂心态一崩就开始坐牢~~(乐~~ # ......
Educational Codeforces Round Rated 149

CodeForces 1837F Editorial for Two

[洛谷传送门](https://www.luogu.com.cn/problem/CF1837F "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1837/F "CF 传送门") 这是一个常规 $\log^2$ 做法。 最大值最 ......
CodeForces Editorial 1837F 1837 for

Codeforces Round 874 (Div. 3)

Codeforces Round 874 (Div. 3) A - Musical Puzzle 思路:记录两个长度字符串的种数 #include<bits/stdc++.h> using namespace std; typedef pair<int,int>PII; typedef pair<s ......
Codeforces Round 874 Div

Educational Codeforces Round 149 (Rated for Div. 2)

Educational Codeforces Round 149 (Rated for Div. 2) A - Grasshopper on a Line 思路:只有两种情况,x整除k时为x-1和1,否则为x void solve() { int x, k; cin >> x >> k; if (x ......
Educational Codeforces Round Rated 149

Codeforces 1439E - Cheat and Win

模拟赛放了道 *3500,结果全场都切了,非常恐怖。 首先考虑怎么样的树是合法的,打个表发现 SG 函数值为 $\sum_{d}2^d·(\text{深度为 d 的点个数}\bmod 2)$,换句话说后手必胜当且仅当每种深度的点数都是偶数。 于是实际上我们只用建出虚树之后树上差分一下求出每个点被覆盖 ......
Codeforces 1439E Cheat 1439 and

[ABC294G] Distance Queries on a Tree 题解

## Description 有一个节点数为 $N$ 的树。边 $i$ 连接 $u_i$ 和 $v_i$,边的权值为 $w_i$。 $Q$ 次询问,询问一共有两种。 ```1 i w``` :改变第 $i$ 条边的权值为 $w$。 ```2 u v``` :输出 $u$ 到 $v$ 的路径距离。 数 ......
题解 Distance Queries 294G Tree

【题解】Codeforces Round 737 (CF1557)

VP 情况: solve:4/5 rank:431st 评价: VP 了一下,我这个 shaber B 直接 5 发罚时,耽误了二十多分钟,以及被 D 各种细节差点搞死。 ## A.Ezzat and Two Subsequences(*800) ### 题目描述: 给定一个序列,将其分为 $2$ ......
题解 Codeforces Round 1557 737

Codeforces Round 837 (Div. 2) F. Hossam and Range Minimum Query

[传送门](https://codeforces.com/contest/1771/problem/F) 大致题意: ** 给一个n,然后给一个数组a, 有m个询问,询问区间[l, r]出现次数为奇数的最小值,若没有输出0, 每次输入的l,r需要异或上上一个答案,在第一个询问的时候认为上一个答案为0 ......
Codeforces Minimum Hossam Round Range

Educational Codeforces Round 143 (Rated for Div. 2) A-D

Educational Codeforces Round 143 (Rated for Div. 2) A. Two Towers void solve(){ int n=read(),m=read(); string s,t; cin>>s>>t; int ans=1; for(int i=0;i ......
Educational Codeforces Round Rated 143

codeforces#1829H.Don't Blame Me(dp)

题解 ``` #include #define io ios::sync_with_stdio(false); #define off cin.tie(0), cout.tie(0); #define all(x) x.begin(),x.end() #define inf 0x3f3f3f3f3f ......
codeforces Blame 1829 Don 39

Codeforces Round 870 (Div. 2)

# Preface 补题,感觉这场挺对口味的说,E直接秒出,虽然刚开始并不觉得能跑得过去,不过写了一发直接艹过去了可海星 F题挺有意思的一个题,不过刚开始没想到只要三次询问就行了所以想偏了,不然也是挺简单的 # A. Trust Nobody 枚举说谎的人的个数$x$,统计出$l_i>x$的个数$c ......
Codeforces Round 870 Div

maximum clique 1 (牛客多校) (转化为图论, 二分图的最大独立集)

题面大意: 给出N个数, 找出最大的子集size 使得 子集中, 任意2个数的 二进制下, 每一位, 至少有2位不同 思路: N 只有5000, 可以直接暴力建边, 转化位图论 2种建边方式: 一种是 能在一个集合的2个数, 建一条边, (没有办法去处理这个问题) 一种是 不能在一个集合的就建一条边 ......
maximum clique

Educational Codeforces Round 148 (Rated for Div. 2) D1. Red-Blue Operations

[Easy Version传送门](https://codeforces.com/contest/1832/problem/D1) [Hard Version传送门](https://codeforces.com/contest/1832/problem/D1) 题目大意: ![](https:// ......

Codeforces Round 732 (Div

## [AquaMoon and Strange Sort](https://vjudge.net/problem/CodeForces-1546C) >有 $n$ 个人从左到右站成一排,从左数第 $i$ 个人的衣服上印着 $a_i$。每个人的朝向可以是朝左、朝右。一开始所有人的方向都是朝右。 > ......
Codeforces Round 732 Div

CodeForces 1827E Bus Routes

[洛谷传送门](https://www.luogu.com.cn/problem/CF1827E "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1827/E "CF 传送门") 比较神奇的题。 定一个非叶子 $r$ 为根。 显 ......
CodeForces Routes 1827E 1827 Bus

Query execution was interrupted, maximum statement execution time exceeded

数据库版本:MySQL 5.7.16 报错信息: ERROR 3024 (HY000): Query execution was interrupted, maximum statement execution time exceeded 检查bug库,发现同样问题: https://bugs.my ......

CodeForces 1784D Wooden Spoon

[洛谷传送门](https://www.luogu.com.cn/problem/CF1784D "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1784/D "CF 传送门") 我怎么连这种 combinatorics 都不会 ......
CodeForces Wooden 1784D Spoon 1784

Educational Codeforces Round 148 (Rated for Div. 2)

# Preface 补题,这场比较简单,E之前的都能写出来,当然D的细节挺多的WA了好几发 感觉时间好不够用啊,想补的题那么多但效率好低,可能要等暑假才能集中攻克了 # A. New Palindrome 统计下出现了一次以上的字符有几种,如果大于等于两种就有解 ```cpp #include #i ......
Educational Codeforces Round Rated 148

Codeforces Round 874 (Div. 3) A-F

Codeforces Round 874 (Div. 3) A. Musical Puzzle map<int,int>mp; void solve(){ mp.clear(); int n=read(),cnt=0; string s; cin>>s; for(int i=0;i<n-1;i++) ......
Codeforces Round 874 A-F Div

Codeforces Gym 103119B - Boring Problem(高斯消元)

考虑建出 AC 自动机,朴素做法是高斯消元,$f_i=\sum\limits_{j=0}^{k-1}f_{to_{i,j}}p_j+1$,复杂度 $O(n^3m^3)$,不能接受。 考虑优化高斯消元的过程,我们定义以下节点为“关键点”: - 根节点 - 对于一个 trie 树(也就是未经过 AC 自 ......
Codeforces 103119B Problem 103119 Boring

Codeforces Round 862 (Div. 2) A-D

Codeforces Round 862 (Div. 2) A. We Need the Zero int a[N]; void solve(){ int n=read(),sum; for(int i=1;i<=n;i++){ a[i]=read(); if(i==1)sum=a[i]; else ......
Codeforces Round 862 A-D Div

Codeforces Round 873 (Div. 2) A~D2

## Codeforces Round 873 (Div. 2) A~D2 ### A. Divisible Array 因为$1$一定整除,构造$a_i=i$,再让$a_1$加上和模$n$的余数 ```c++ void work() { int n; cin >> n; vector a(n + ......
Codeforces Round 873 Div D2

Educational Codeforces Round 148 (Rated for Div. 2) A~E

## Educational Codeforces Round 148 (Rated for Div. 2) A~E ### A. New Palindrome 对于奇回文串不能统计中心的字符,然后判断是否有不同的字符 ```c++ void work() { string s; cin >> s; ......
Educational Codeforces Round Rated 148

AtCoder Regular Contest 130 E Increasing Minimum

这题太神仙了吧!感觉还不是很懂,但是尽力理一下思路。 设 $t_x$ 为最大的 $j$ 使得 $i_j = x$,不存在则 $t_x = 0$。 设 $1 \sim n$ 的数按照 $t$ 从小到大排序后是 $p_1, p_2, ..., p_n$,设 $q_i$ 为 $i$ 在 $p$ 中的排名, ......
Increasing AtCoder Regular Contest Minimum

Codeforces Round 874 (Div. 3) A-G

[比赛地址](https://codeforces.com/contest/1833) ## A. Musical Puzzle 题意:给出一个字符串,求有多少个不同的长度为2的子串 ### Solution 直接set存即可 ```C++ void solve() { int n;cin>>n; ......
Codeforces Round 874 A-G Div

Codeforces Round 874 (Div. 3)

# [A.Musical Puzzle](https://codeforces.com/contest/1833/problem/A "A.Musical Puzzle") ### 题意: 用最少的长度为2的字符串按一定规则拼出s。规则是:前一个字符串的尾与后一个字符串的首相同。 ### 分析: 统 ......
Codeforces Round 874 Div

CodeForces1061C Multiplicity

## 题面翻译 从序列 $\{a_1,\ a_2,\ ..\ ,\ a_n\}$ 中选出**非空**子序列 $\{b_1,\ b_2,\ ..\ ,\ b_k\}$,一个子序列合法需要满足 $\forall\ i \in [1,\ k],\ i\ |\ b_i$。求有多少互不相等的合法子序列,答案对 ......
Multiplicity CodeForces 1061C 1061

Codeforces 874 div3 (A-G)

# [Codeforces 874 div3](https://codeforces.com/contest/1833) ## A ### 题意 计算每两个相邻字符的不同种类 ## B ### 题意 重排一个数组b,使得$|a_i-b_i|\leq k$ ### 思路 根据相对大小去一一对应,这样每 ......
Codeforces div3 874 A-G div

【做题记录】CodeForces343D Water Tree

题面翻译 - 给出一棵以 $1$ 为根节点的 $n$ 个节点的有根树。每个点有一个权值,初始为 $0$。 - $m$ 次操作。操作有 $3$ 种: 1. 将点 $u$ 和其子树上的所有节点的权值改为 $1$。 2. 将点 $u$ 到 $1$ 的路径上的所有节点的权值改为 $0$。 3. 询问点 $u ......
CodeForces Water 343D Tree 343