Educational

Educational Codeforces Round 155 (Rated for Div. 2)

Educational Codeforces Round 155 (Rated for Div. 2) A. Rigged! 解题思路: 若存在\(s[i] >= s[1]\)并且\(e[i] >= e[i]\),那么答案为\(-1\). 否则,答案为\(s[1]\). 代码: #include < ......
Educational Codeforces Round Rated 155

Educational Codeforces Round 155 (Rated for Div. 2)

比赛链接 A. Rigged! 题目链接 就是一个比较简单的模拟就可以解决,如何判断能不能第一只需要考虑比他力量大的耐力是不是也比他大就行,而只要比他大,他就不可能第一,否则输出他的力量作为标杆就行,这样也可以避免比他力量小的也可以举起来。 #include<bits/stdc++.h> using ......
Educational Codeforces Round Rated 155

Educational Codeforces Round 97 (Rated for Div 2) G. Death DBMS

Problem - G - Codeforces 题意 给定n个字符串,每个字符串有一个值val,n次询问,每次给一个字符串,询问给定n个字符串中是询问字符串子串的值的最大值 分析 多模式匹配,从中找到给定串的子串,想到建立ac自动机,对于给定字符串,在自动机上面匹配时,沿fail指针向上跳并求最大 ......
Educational Codeforces Death Round Rated

Educational Codeforces Round 123 - D(思维题)

目录D. Cross Coloring D. Cross Coloring 题意 $n \times m $ 的方格纸上进行 q 次操作,每次操作选择某整行 x 和某整列 y,使得行 x 和列 y 均涂上 k 种颜色中的一种。问你最终的方案数 思路 代码 //>>>Qiansui #include< ......
Educational Codeforces 思维 Round 123

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

传送门:edu154/div2 A. Prime Deletion 题意:给定一个0-9的排列,要求一个长度>=2的子序列,使得该子序列是质数 做法:考虑31或者13即可。不过当时没有立刻想到,感觉1000以内的质数必有答案,打了暴力。用时就多了点。 Code #include<bits/stdc+ ......
Educational Codeforces Round Rated 154

Educational Codeforces Round 143

A. Two Towers #include <bits/stdc++.h> using namespace std; #define int long long #define mp make_pair using pii = pair<int, int>; using vi = vector<i ......
Educational Codeforces Round 143

Educational Codeforces Round 107

依然是四题,但是感觉太久没打,好像变得迟钝了。 B题大概就是令 \[c={10}^k, a=c*3^k, b=c*2^k \]C的话直接暴力维护每种颜色的第一个位置就行,反正只有50个 D的话刚开始没什么想法,构造题什么的真的不会啊 打表之后发现,对于k,在cost为0的情况下,最多能造出长度为\( ......
Educational Codeforces Round 107

Educational Codeforces Round 117 (Rated for Div. 2) B. Special Permutation

给三个正整数数 \(n, a, b\) ,\(n\) 是偶数。写出 \(n\) 的任意一个排列满足左边一半的最小值等于 \(b\) 且右边一半的最大值等于 \(a\) 。 性质: 控制某个区间的最小值,需要让这个区间的数尽可能大 控制某个区间的最大值,需要让这个区间的数尽可能小 于是让排列左半的数尽 ......

Educational Codeforces Round 118 (Rated for Div. 2) A. Long Comparison

白板上左右写上两个数,每个字的形式表示为:一个正整数 \(x\) 和 \(p\) 个末尾 \(0\) 。 询问左右两个数的大小关系。 假设左边为 \(x_1, p_1\) ,右边为 \(x_2, p_2\) 。 先看数位长度 若 \(dig_{x_1} + p_1 < dig_{x_2} + p_2 ......

Educational Codeforces Round 100

B. Find The Array 对于条件二来说,1 是万金油的存在,所以我们只需要把奇数位置或偶数位置全部变成 1 即可。因为要求差值小于\(\frac s 2\),所以我可以求出奇偶位的和修改较小值即可。 #include <bits/stdc++.h> using namespace std ......
Educational Codeforces Round 100

Educational Codeforces Round 101

C. Building a Fence 首先相邻的两个栅栏是否相交的判断可以转换为两个栅栏的底的距离差,这样实际上我们并不需要维护出栅栏,只需要维护底的位置即可。 假设上一个栅栏可摆放的位置是\([x,y]\),则与之相交的栅栏应该摆放在\([x-k+1,y+k-1]\)。如果当前地面高度是\(h\ ......
Educational Codeforces Round 101

Educational Codeforces Round 102

C. No More Inversions 首先我们先来看对 1 2 3 ... k-1 k k-1 ... 3 2 1 这样的序列进行题目中的变化操作。 k = 2 1 2 1 逆序对1个 2 1 2 逆序对1个 k = 3 1 2 3 2 1 逆序对4个:(2,1) (3,2) (3,1) (2 ......
Educational Codeforces Round 102

Educational Codeforces Round 150

A. Game with Board 当\(n>4\)时,Alice 可以把序列变成n-2,1,1,Bob只能操作成n-2,2,此时 Alice获胜。 #include <bits/stdc++.h> using namespace std; #define int long long using ......
Educational Codeforces Round 150

【题解】Educational Codeforces Round 141(CF1783)

评价:educational A.Make it Beautiful 题目描述: 如果一个数组中存在一个数恰好等于该数前面所有数之和,那么这个数组就是丑的。如果一个数组不是丑的,就是美的。 比如说: 数组 $ [6, 3, 9, 6] $ 是丑的,因为 \(9 = 6 + 3\) ; 数组 $ [5 ......
题解 Educational Codeforces Round 1783

Educational Codeforces Round 34 (Rated for Div. 2) C(multiset、思维)

C. Boxes Packing 思路:每一次选择一段递增的子段, 将其删除, 最高的一个会能够被看到。这个过程可以用 std::multiset 模拟, 主要是两个函数的应用: extract(x):删除集合中的一个 $ x $,upper_bound(x):返回集合中第一个大于 $ x $ 的元 ......
Educational Codeforces multiset 思维 Round

【题解】Educational Codeforces Round 142(CF1792)

没有手速,再加上被 E 卡了,废掉了。 A.GamingForces 题目描述: Monocarp 正在玩电脑游戏。他打算杀死 \(n\) 个怪兽,第 \(i\) 个的血量为 \(h_i\)。 Monocarp 的角色有两个魔法咒语如下,都可以以任意顺序用任意次(可以不用),每次使用相当于一次操作。 ......
题解 Educational Codeforces Round 1792

Educational Codeforces Round 132 (Rated for Div. 2) B. Also Try Minecraft

一个世界地图用一个长为 \(n\) 的数组表示,\(a_i\) 代表坐标 \(i\) 的高度。若下一块区域的高度为 \(y\) ,当前区域的高度为 \(x\) ,则一次行走会受到 \(max(y - x, 0)\) 点下落伤害。 有 \(q\) 个询问,每个询问独立,给定起点和终点坐标 \(s, t ......
Educational Codeforces Minecraft Round Rated

Educational Codeforces Round 130 (Rated for Div. 2) B. Promo

有 \(n\) 件商品,第 \(i\) 件的价格是 \(p_i\) ,若买至少 \(x\) 件商品,则其中最便宜的 \(y\) 件免费。给 \(q\) 个询问,每次给出 \(x, y\) ,回答最多能免费的价值。 按大到小排序,求前缀和 \(S_{i}\) 表示买前 \(i\) 件商品需要的开销。 ......
Educational Codeforces Round Rated Promo

【题解】Educational Codeforces Round 143(CF1795)

A.Two Towers 题目描述: 有 \(a,b\) 两座由红蓝色方块垒成的塔,其中 \(a\) 的高度为 \(n\) ; \(b\) 的高度为 \(m\) ,用 R 代表红色;用B代表蓝色。 你可以多次把其中一座顶端的方块移到另一座的顶端(可以不移动)。问有没有一种方法可以使两座塔中均没有连续 ......
题解 Educational Codeforces Round 1795

$Educational Codeforces Round 138 (Rated for Div. 2)$

## $A. Cowardly Rooks$ 我模拟了一遍,因为我没看到题目中*给出的矩阵已经合法*, $a$ 题第一次写这么多。 实验室同事跟我说只要判断 $n$ 和 $m$ 的大小关系就行了。 ```cpp int x[N],y[N],m,n; bool check(){ for(int i=1 ......
Educational Codeforces Round Rated 138

【题解】Educational Codeforces Round 144(CF1796)

被 C 卡了。 最后被 E 的各种分讨劝退,但是同时也学习到了一种换根 dp 的简单写法。 评价:It's educational for me. ## A.Typical Interview Problem ### 题目描述: 有一个包含 F 和 B 的字符串,最开始是空的。我们开始从 $1$ 向 ......
题解 Educational Codeforces Round 1796

Educational Codeforces Round 120

# C. Set or Decrease 可以得到两个规律 - 修改操作一定是把较大的数变成最小的数更优 - 减一对谁操作都不影响结果 根据以上两个规律有可以总结出最优操作策略 - 对最小值先做若干次减法 - 把最大的若干个数变成最小值 已知策略后,我们发现因为值域很大,所以不能枚举最小值减的次数, ......
Educational Codeforces Round 120

Educational Codeforces Round 138 (Rated for Div. 2) B. Death's Blessing

这是一个电脑游戏,$n$ 个怪物排成一行,第 $i$ 个怪物的血量为 $a_i$ 并且它的亡语强度为 $b_i$ 。规则是: * 玩家每秒可以削减一只怪物的一点血量。 * 第 $i$ 只怪物死亡后会释放亡语,它两侧的怪物血量会得到 $b_i$ 的增幅血量。边界上的怪物只能对它的邻居进行亡语增幅。 * ......
Educational Codeforces Blessing Death Round

Educational Codeforces Round 119

# B. Triangles on a Rectangle 因为保证了每一个边上都有点,所以相当于三角形的高已经确定了。最大化底即可。 ```cpp #include using namespace std; #define int long long const int inf = 1e15; u ......
Educational Codeforces Round 119

Educational Codeforces Round 151 (Rated for Div. 2) B. Come Together

给三个点 $A, B, C$ ,两个人一开始都在 $A$ 点,一个人希望最快到达 $B$ ,另一个人希望最快到达 $C$ ,且他们希望尽可能走一条路径。则这条路径最长是多长。 经典的高维可以由低维叠加的问题。 * 坐标问题 * 动态规划问题 并非所有高维问题都可由低维叠加,但任何二维问题都可由一维叠 ......
Educational Codeforces Together Round Rated

Educational Codeforces Round 149 (Rated for Div. 2) B. Comparison String

给一个长度为 $n$ 的字符串 $s$ ,只包含字符“”。 一个长度为 $n + 1$ 的数组 $a$ 与 $s$ 是兼容的当且仅当对于任意 $i$ : 1. $s_i$ is $$ ,当且仅当 $a_i > a_{i - 1}$ 定义一个数组的 $cost$ 为这个数组中不同数的个数。 求一个 $ ......

Educational Codeforces Round 143 (Rated for Div. 2) B. Ideal Point

给 $n$ 条一维线段,一条端点为 $l, r$ 的线段可以覆盖 $\forall i, l \leq i \leq r$ 。定义 $f(x)$ 为点 $x$ 被线段覆盖的次数。一个点 $x$ 称为是 “完美的” 如果 $y \neq x, f(x) > f(y)$ 。 给一个点 $k$ ,询问是否 ......
Educational Codeforces Round Rated Ideal

【题解】Educational Codeforces Round 145(CF1809)

## A.Garland ### 题目描述: 有 $4$ 只灯泡,第 $i$ 只灯泡的颜色为 $s_i$ 。 一开始,所有灯泡都是关着的,你需要把它们都打开。你可以进行数次操作,每次操作改变一个灯泡的状态,即打开原本关着的灯泡或关上原本亮着的灯泡。第一次操作可选择任何灯泡,此后每一次被操作的灯泡的颜 ......
题解 Educational Codeforces Round 1809

Educational Codeforces Round 154 (Rated for Div. 2)

# Educational Codeforces Round 154 (Rated for Div. 2) [比赛链接](https://codeforces.com/contest/1861) 我都快忘了还有这一场比赛,今天打开cf看见这场比赛正好有时间就补了!!! 2023.9.3也许是出去玩了 ......
Educational Codeforces Round Rated 154

Educational Codeforces Round 7 A - E

# [Educational Codeforces Round 7](https://codeforces.com/contest/622) [TOC] ## [A - Infinite Sequence](https://codeforces.com/contest/622/problem/A) ......
Educational Codeforces Round