codeforces different arrays 1783d

codeforces #865 div1A

A. Ian and Array Sorting 思路:首先我们可以从前往后做一遍,把除了最后一个元素其他所有数都变成和第一个数一样的数,然后假如前n-1个数个数为偶数,这样我们分组进行操作,一定可以把所有数变成无限小,也就是说一定会有解,也就是说n为奇数一定有解,我们考虑n为偶数的情况,n为偶数, ......
codeforces div1A div1 865 div

Competition Set - Codeforces

这里记录的是这个账号的比赛情况。 Codeforces Round 869 (Div. 1) 2023-4-29 Solved:3/6 2302->2350 Good Bye 2022: 2023 is NEAR 2022-12-30 Solved:5/8 2218->2302 Codeforces ......
Competition Codeforces Set

[CodeForces-545A]题解(C++)

Part I Preface 原题目(Luogu) 原题目(CodeForces) Part II Sketch 给定一个正整数 $n$,表示汽车数量。 给定一个 $n \times n$ 阶矩阵 $A$,第 $i$ 行 $j$ 列上的数字表示 $i$ 车与 $j$ 车的对撞情况。 $\begin{ ......
题解 CodeForces 545

[CodeForces-545A]题解(C++)

Part I Preface 原题目(Luogu) 原题目(CodeForces) Part II Sketch 给定一个正整数 $n$,表示汽车数量。 给定一个 $n \times n$ 阶矩阵 $A$,第 $i$ 行 $j$ 列上的数字表示 $i$ 车与 $j$ 车的对撞情况。 $\begin{ ......
题解 CodeForces 545

【组会】difference

difference我一直以为是差异,但有差的意思(a-b的这个-) 所以这篇文章的思路就是分辨出什么是人,什么是静态物体,然后通过相位变化算出人和静态物体的位移,然后将算出的人的位移减去静态物体的位移,就相当于减去了雷达微小运动的影响 ......
difference

Educational Codeforces Round 147 (Rated for Div. 2) (贪心)

###原题链接:https://codeforces.com/contest/1821/problem/D * 题意:从1开始走,走的给定区间的值要k次。且shift按了要松开,代表走了一个区间除了往右的次数,还要多两次按shift的次数, 求最小次数。 * 思路: 1. 先把不可能的情况列出来,就 ......
Educational Codeforces Round Rated 147

Codeforces Round 869 (Div. 2)

从这一篇开始,比较重要的题目我会把题面放上 A. Politics 傻逼题目,傻逼题面,傻逼出题人 明明一句话能说清楚的事情为啥放样例了说啊? 不然你说这个东西有多项式解法吗? 一句话题解,和我不同意见的,都得死 #include <bits/stdc++.h> #define ll long lo ......
Codeforces Round 869 Div

Codeforces Round 867 (Div. 3)

A. TubeTube Feed 分析: 从所有a[i]+i-1<=t的选择种取个max即可 code: #include <bits/stdc++.h> using namespace std; const int N = 55; int a[N], b[N]; int main() { std: ......
Codeforces Round 867 Div

Codeforces 908H - New Year and Boolean Bridges(FWT)

一道挺有意思的题,并且感觉有点诈骗的成分在内( 首先考虑分析三种字符的性质: 显然任意两点 $i,j$ 之间要么 $i$ 可以到达 $j$,要么 $j$ 可以到达 $i$,否则 A O X 三个一个都不能满足。 如果两点间的状态是 A,那么这两点必须在同一强连通分量内。 如果两点间的状态是 X,那么 ......
Codeforces Boolean Bridges 908H Year

Uncaught Error: Objects are not valid as a React child (found: object with keys {content, key, duration}). If you meant to render a collection of children, use an array instead(转)

转自:react报错 Uncaught Error: Objects are not valid as a React child (found: object with keys {a} ... 报错信息分析 Uncaught Error: Objects are not valid as a R ......

AtCoder Regular Contest 128 E K Different Values

洛谷传送门 AtCoder 传送门 考虑判断有无解。把序列分成 $c = \left\lceil\frac{len}{k}\right\rceil$ 段,则 $\forall a_i \le c$ 且 $\sum\limits_{i=1}^n [a_i = c] \le ((len - 1) \bm ......
Different AtCoder Regular Contest Values

4.[1201D - Treasure Hunting](https://codeforces.com/problemset/problem/1201/D)

4.1201D - Treasure Hunting 题目意思: 在一个n*m的地图上面,左下角的坐标是(1,1),最开始你位于左下角,一秒钟你可以进行往左或者往右的操作,你只能在一些特殊的列上面进行往上移动的操作,你不可以往下移动。现在告诉你k个宝藏的坐标信息以及哪些列是允许往上的,问最后至少要几 ......
1201 codeforces problemset Treasure Hunting

js基础之Array类型常用方法

栈:LIFO(last-in-first-out)后进先出 队列:FIFO(first-in-first-out)先进先出 数组方法 arr.pop() 返回最后一项的值 arr.push() 在数组最糊一项追加,返回当前数组长度 arr.shift() 返回第一项的值 arr.unshift() ......
常用 类型 基础 方法 Array

Codeforces Round 869 (Div. 2) A-D题解

比赛地址 A. Politics 题意:有n个人对m个决案进行投票,对于每一个决案如果票数相同则所有人都离场,反之票数少的一方离场,现在提前知道了每个人的意见,让一些人参与投票,在保证第一个人不离场的情况下最终剩余人数最多是多少 Solution 把和第一个意见不同的给去掉就行了 void solv ......
题解 Codeforces Round 869 A-D

Codeforces 914H - Ember and Storm's Tree Game(计数)

我这个低能儿怎么这个题调了这么久啊,废了/dk 非常烦的做法,不过也可以看看,代码也不算太难写( 首先注意到很诈骗的一件事情是,只要这个序列 $a$ 是单峰的或者单谷的(当然,递增递减序列也算在内),都恰有两种方式选择 $(i,op)$ 使得操作完后的序列的单调的,并且显然选树的 Ember 有必胜 ......
Codeforces Ember Storm 914H Game

Chemistry Experiment Codeforces Round 247 (Div. 2) 线段树动态开点,二分

第一次写的时候还不会线段树的动态开点,写了一个是线段树但是是$O(N^2)$的写法,现在用动态开点武装了自己,会了正解$O(qlog n^2)$。首先建立一个权值线段树,但这里的权值很大,通过动态开点去建树来节省空间,对于两种操作: 操作1,常见的动态开点的单点修改 操作2,二分答案,然后在线段树上 ......

Codeforces 280C Game on Tree

设 $p_i$ 为 $i$ 涂色或不涂色,$1$ 为涂,$0$ 为不涂,答案即为 $E[\sum_{i = 1}^n p_i]$ 然后转化一下柿子:$\sum_{i=1}^nE[p_i]$,这就很好求了,单独求每个点 $E[p_i]$ 的值就行了 考虑对于 $u$ 点,$p_u = 1$,即能被涂需 ......
Codeforces 280C Game Tree 280

Educational Codeforces Round 147 (Rated for Div. 2) A~E 题解

A Link。 模拟,代码。 B Link。 模拟,代码。 C Link。 我们设 $c$ 为最后相同的字符。 性质:我们一定不会删除字符 $c$。 因此以 $c$ 为最后字符的操作次数就是不包含字符 $c$ 的极大段的最小操作次数的最大值。 对于一个长度为 $l(l\ge 1)$ 的段,它的最小操 ......
题解 Educational Codeforces Round Rated

[Javascript] Avoid mutation, Array.prototype.toReversed() vs reverse()

reverse()mutates the original array, return the reference point to the original array. The toReversed() method of Array instances is the copying count ......

[Javascript] avoid mutation: Array.prototype.toSpliced() vs splice()

Array.prototype.splice()mutates the original array. To avoid mutation, we use Array.prototype.slice(). new method Array.prototype.toSpliced() return a ......

[Javascript] Avoid mutation, Array.prototype.toSorted() vs sort()

sort(), mutates the original array, and return the reference to original array and sorted. The toSorted() method of Array instances is the copying ver ......
Javascript prototype mutation toSorted Avoid

[Javascript] Array.prototype.with

Prevously, when we want to upate an item inside a array: const items = [ {id: 1, name: 'a'}, {id: 2, name: 'b'}, {id: 3, name: 'c'}, {id: 4, name: 'd' ......
Javascript prototype Array with

Codeforces 894D Ralph And His Tour in Binary Country

预处理出对于 $u$ 节点其子树内节点(包括 $u$)与 $u$ 的距离,从小到大排序得到 $ds_u$ 同时对 $ds_u$ 进行前缀和处理 $dh_{u, i} = \sum\limits_{j = 1}^{i} ds_{u, j}$ 这样设 $tot$ 为 $ds_u$ 二分得到的 $ds_{ ......
Codeforces Country Binary Ralph 894D

Codeforces Round 868 (Div. 2)

题目链接 C 核心思路 一定要看清楚题目,题目是要我们最小哦。 首先看可不可抽像为数学表达式,答案肯定是可以的。 x=p1^d1*p2^d2*..*pn^dn; D=\sum{(d1+1)*(d2+1)*(d3+1)*...(*(dn+1))}; 这个D表示的x的约数的个数,这个公式还是很好理解的, ......
Codeforces Round 868 Div

Codeforces 1229B Kamil and Making a Stream

$\gcd$ 一个性质:对于正整数 $x$, 重复 $x\leftarrow \gcd(x, i)$($i\ge 0$)直到 $x = 1$,$x$ 出现的值个数上限为 $\log_2(x)+1$ 证明:考虑到 $x$ 是逐渐变小,则在 $x$ 变小的情况下,对于 $x = \prod_{i=1}^ ......
Codeforces Making Stream 1229B Kamil

Codeforces Round 869 (Div. 1)

C 根据初中数学知识,恒成立问题考虑未知数x每一项的系数,然后得到(d+1)个等式,根据前两个就可以推出$s=\frac{b_{d-1}-a_{d-1}}{da_d}$且$a_d=b_d$ 但是一直不会用题目给的n个点值求出最高的两项系数(或它们的比值),并且怀疑是否把(d+1)个等式全部用到会更好 ......
Codeforces Round 869 Div

Codeforces Gym 103439D - LIS Counting(猜结论+状压)

一道需要一些猜结论技巧的中档题。 首先突破口在于排列长度恰好等于不是额外输入的某个数 $k$ 而是 LDS 与 LIS 的乘积,这显然启示我们去找一些性质。根据 dilworth 定理,最长反链等于最小链覆盖,故 LIS 的长度,就是最少需要的递减数列的个数使得每个元素被覆盖至少一次,而每个递减数列 ......
Codeforces Counting 结论 103439D 103439

Codeforces Round 869 (Div. 2) A-C

A. Politics 思路 与第 $1$ 个人的意见不同的人都要删除 代码 #include<bits/stdc++.h> using namespace std; int main() { int T; cin>>T; while(T--) { int n,m; cin>>n>>m; strin ......
Codeforces Round 869 A-C Div

Codeforces Round 869 (Div. 2)

Preface 一把回到紫名还是很舒服的,D题手比较稳猜了点性质水过 主要还是C脑抽了想了挺久才看出来是个丁真题,不然最后过了D之后30min可以看看E的 由于要写学校的图论专题所以接下来一段时间的CF补题计划就要先停一停了 A. Politics 傻逼题,当某个人的串和第一个人有任意一个位置不同时 ......
Codeforces Round 869 Div

Codeforces Round 823 (Div. 2)C

C. Minimum Notation 思路:我们可以进行的操作时将一个位置的数删除然后在任意位置处添加一个比当前数大1并且小于9的数,所以我们的操作只会让一个数变大,我们统计一个最大值的后缀,贪心的考虑如果当前数的后面有比他小的数的话,我们就需要让这个小的数往前走才能使字典序变小,如果当前值小于< ......
Codeforces Round 823 Div