codeforces distance minimum maximum

Codeforces 1737G - Ela Takes Dancing Class(平衡树)

数据结构好题。 先考虑如果 $s_i$ 全是 $1$ 怎么做。考虑一个非常特殊的状态:如果当前最靠左的舞蹈者跳一步就能跳到最靠右的舞蹈者的右边,那么这样的局面性质其实是非常完美的。因为容易归纳证明,这样的局面下,每一步最靠左的舞蹈者跳一步都能跳到最靠右的舞蹈者的右边,这样一来,如果维护出了初始局面下 ......
Codeforces Dancing 1737G Class Takes

[LeetCode] 1347. Minimum Number of Steps to Make Two Strings Anagram 制造字母异位词的最小步骤数

You are given two strings of the same length `s` and `t`. In one step you can choose **any character** of `t` and replace it with **another character* ......
字母 LeetCode 步骤 Anagram Minimum

[ABC201E] Xor Distances 题解

[Xor Distances](https://www.luogu.com.cn/problem/AT_abc201_e) ### 题目大意 给定一颗带边权无根树,定义 $\text{dis}(i,j)$ 表示 $i,j$ 两点在树上的最短路径的边权的异或和。求: $$\sum_{i=1}^n\su ......
题解 Distances 201E ABC 201

Codeforces Round 876 (Div. 2)

# Preface DP腐乳闪总出列! (本来以为大掉分的一把,但这个号因为挺新的所以竟然还能上挺多分的,压线完成了5场上紫) 早知道去做E题了,感觉CF真得要看题目相性,有些题目就是一眼感觉不适合自己的说 # A. The Good Array 一个要动点脑子的签到题,因为$a_1,a_n$必须等 ......
Codeforces Round 876 Div

Codeforces Round 876 (Div. 2)题解

# [Codeforces Round 876 (Div. 2)](https://codeforc.es/contest/1839 "Codeforces Round 876 (Div. 2)") ## [A. The Good Array](https://codeforc.es/contest ......
题解 Codeforces Round 876 Div

2023.5 codeforces 杂题选做

## 2023.5 codeforces 杂题选做 #### [E. Location](https://codeforces.com/contest/1732/problem/E) $n\le 5\times 10^4$ 的范围,并且区间赋值、区间维护最值,可以考虑分块。然后对于散块的修改可以直接 ......
codeforces 2023.5 2023

[LeetCode] 2101. Detonate the Maximum Bombs

You are given a list of bombs. The range of a bomb is defined as the area where its effect can be felt. This area is in the shape of a circle with the ......
LeetCode Detonate Maximum Bombs 2101

Codeforces 1833E Round Dance

看到 `shortest paths` 来做的,但是好像没啥关系也没啥难度。 首先能知道一个连通块肯定一次就能跳完,所以可以把连通块缩出来。 然后有一个性质,记 $cz_i$ 为 $i$ 连通块内点种通过已知边推出的度数为 $1$ 的个数为 $cz_i$,则 $cz_i\bmod 2 = 0$。 记 ......
Codeforces 1833E Round Dance 1833

Maximum Strictly Increasing Cells in a Matrix

Maximum Strictly Increasing Cells in a Matrix Given a 1-indexed m x n integer matrix mat, you can select any cell in the matrix as your starting cell. ......
Increasing Strictly Maximum Matrix Cells

【python】Python报错:RecursionError: maximum recursion depth exceeded in comparison

问题描述 今天测试程序的时候报错了 RecursionError: maximum recursion depth exceeded 通过查阅资料发现原因是查询过相关文档和资料后才发现了问题原因,python的递归深度是有限制的,默认为1000。当递归深度超过1000时,就会报错。 解决方案 可以将 ......

Codeforces 1515I - Phoenix and Diamonds(值域倍增+线段树)

首先 $c$ 很大,因此复杂度跟 $c$ 有关的项肯定只能是 $\log c$ 之类的。 类比 IOI2021 dungeons 的套路,我们**对值域进行分层**,假设 $c\in[2^{\omega-1},2^{\omega})$,考虑令重量在 $\ge 2^{\omega-1}$ 的物品为“重 ......
值域 线段 Codeforces Diamonds Phoenix

Codeforces Round 875 (Div. 2)B-D

原题链接:https://codeforces.com/contest/1831 原文:https://www.cnblogs.com/edgrass/p/17440602.html (B) Array merging 主体思想是找到ab数组的最长相同字串(c中操作可实现连续) 1 #include ......
Codeforces Round 875 B-D Div

Maximum call stack exceeded(超出最大调用堆栈)错误是什么意思?

你有没有遇到过类似的错误?发生此错误是因为调用堆栈已超出其限制。但是,这是什么意思? 首先,让我们了解什么是调用堆栈。 (https://www.java567.com,搜"javascript") 调用堆栈 调用堆栈是 JavaScript 中的一种数据结构,其中包含正在执行的函数。此结构采用后进 ......
堆栈 exceeded 意思 错误 Maximum

Educational Codeforces Round 149 (Rated for Div. 2)

# A. Grasshopper on a Line ```cpp #include using namespace std; #define int long long void solve(){ int x , k; cin >> x >> k; if( x % k == 0 ){ cout > ......
Educational Codeforces Round Rated 149

【Oracle】Resize your Oracle datafiles down to the minimum without ORA-03297

--In non-multitenant DB set linesize 1000 pagesize 0 feedback off trimspool on with hwm as ( -- get highest block id from each datafiles ( from x$ktfb ......
Oracle datafiles minimum without Resize

Codeforces Round 875 (Div. 2) 题解 A ~ D

## [A](https://codeforces.com/contest/1831/problem/A). Twin Permutations ### 题目大意 题目给定一个 $1\sim n$ 的排列 $a$ ,现在想求一个排列 $b$, 使得对于 $i #include #include #d ......
题解 Codeforces Round 875 Div

Codeforces Round 875 (Div. 2) A-D

## A. Twin Permutations 题意:给出一个由[1,2,...,n]组成的数组a,构造另一个由[1,2,...,n]组成的数组b,使得a[1]+b[1]>n; for(int i=1;i>a[i]; } for(int i=1;i>n; for(int i=1;i>a[i]; fo ......
Codeforces Round 875 A-D Div

Codeforces Round 875 (Div

# Codeforces Round 875 (Div. 2) C-D题解 ### C [Problem - C - Codeforces](https://codeforces.com/contest/1831/problem/C) 我们发现题述所形成的父亲节点一定比子节点先画出,并且如果子节点顺 ......
Codeforces Round 875 Div

Codeforces Round 875 (Div. 2)

# Preface 难得现场打一次,这天下午打了三个半小时的校内赛,然后八点打了两小时ARC,最后再接上两个半小时的CF真是爽歪歪 不过有一说一其实很多时候都在坐牢,这场CF也差不多,一个小时写完ABCD然后开始坐牢,其实E基本想出来了但是没想到用随机赋值的方法来实现 不过由于这场手很稳因此排名极高 ......
Codeforces Round 875 Div

Codeforces Round 874 (Div. 3)

# A. Musical Puzzle ```cpp #include using namespace std; void solve(){ int n; string s; cin >> n >> s; set cnt; for( int i = 0 ; i + 1 > t; while( t - ......
Codeforces Round 874 Div

Codeforces Round 875 (Div. 2) A-D

# Codeforces Round 875 (Div. 2) ## A. Twin Permutations ```c++ int a[N]; void solve(){ int n=read(); for(int i=1;i0?"YES":"NO"); //puts(ans>0?"Yes":"N ......
Codeforces Round 875 A-D Div

CodeForces 1830D Mex Tree

[洛谷传送门](https://www.luogu.com.cn/problem/CF1830D "洛谷传送门") [CF 传送门](https://codeforces.com/contest/1830/problem/D "CF 传送门") 考虑答案的下界。 对整棵树进行二分图染色,我们得到答案 ......
CodeForces 1830D 1830 Tree Mex

CodeForces 1830C Hyperregular Bracket Strings

[洛谷传送门](https://www.luogu.com.cn/problem/CF1830C "洛谷传送门") [CF 传送门](https://codeforces.com/contest/1830/problem/C "CF 传送门") 每一步思路都非常自然的题。 考虑先从一些简单的 cas ......

Codeforces Round #875 (Div. 2)

# Codeforces Round #875 (Div. 2) [bilibili: Codeforces Round #875 (Div. 2) 实况 | 完成度 \[4.01 / 6\]](https://www.bilibili.com/video/BV1bo4y137he) ## A `` ......
Codeforces Round 875 Div

Codeforces Round 875 (Div. 2) A~D

# Codeforces Round 875 (Div. 2) A~D ### A. Twin Permutations 构造$a[i]+b[i]=n+1$ ```c++ void work() { int n; cin >> n; rep (i, 1, n) { int x; cin >> x; ......
Codeforces Round 875 Div

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

## [A](https://codeforces.com/contest/1837/problem/A). Grasshopper on a Line ### 题目大意 给定两个整数 $x$ 和 $k$,我们需要规划一条路线,从 $(0,0)$ 走到 $(0, x)$,同时满足我们每次走的距离不能 ......
题解 Educational Codeforces Round Rated

力扣 662 https://leetcode.cn/problems/maximum-width-of-binary-tree/

需要了解树的顺序存储 如果是普通的二叉树 ,底层是用链表去连接的 如果是满二叉树,底层用的是数组去放的,而数组放的时候 会有索引对应 当前父节点是索引i,下一个左右节点就是2i,2i+1 利用满二叉树的索引特征 所以需要对每个节点进行一个索引赋值,赋值在队列中,队列用数组表示 核心代码如下 publ ......

Codeforces 1740I - Arranging Crystal Balls

(注:默认下标 1-indexed) 考虑一个数组被清零的充要条件:记 $b_i=a_{i}-a_{(i+n-2)\bmod n+1}$,那么最终 $a_i=0$ 当且仅当 $b_i=0$ 且 $a_1=0$。 思考一次操作的影响:假设我们对 $[x,x+k-1]$ 这段环上的区间进行了 $+v$, ......
Codeforces Arranging Crystal 1740I Balls

Educational Codeforces Round 149 (Rated for Div. 2)(A~F)

A. Grasshopper on a Line 题意:给出n,k,从0开始,每次可以加一个数,最快到达n需要,输出首先跳几次,然后每次跳多少,限制只有一个跳的长度不能整除k。 分析:n%k,有余直接跳,没余数,先跳一个,再跳剩余的长度。 代码: ``` #include #include #inc ......
Educational Codeforces Round Rated 149

Codeforces 1444E - Finding the Vertex

非常神秘的一道题,当之无愧的 *3500。 首先考虑转化题意。考虑一种决策树,由于我们每次问一条边之后,相当于会根据信息删掉两个连通块中的一个,因此一种决策树实际上对应了原树的一棵边分树。而为了让最坏情况下的询问次数最少,我们目标实际上是最小化边分树的深度。 考虑借鉴 [P5912 JAS](htt ......
Codeforces Finding Vertex 1444E 1444