codeforces resort round 878
[Codeforces] CF1538F Interesting Function
CF1538F Interesting Function 题目传送门 题意 给定两个正整数 \(l, r\)(\(l < r\)),将 \(l\) 不断加 \(1\) 直到 \(l = r\),求出这一过程中 \(l\) 发生变化的位数总数。 位数变化指: \(l=909\),将 \(l+1\) 后 ......
codeforces比赛(1):codeforces 918_div4
A、Odd One Out 跳转原题点击此:A题地址 1、题目大意 给你三个数,其中两个是相等的,问你还有一个不相等的数是多少。 2、题目解析 直接暴力枚举即可,只要找到两个数相等,那么答案就是另一个数。 #include<bits/stdc++.h> using namespace std; in ......
[Codeforces] CF1536C Diluc and Kaeya
CF1536C Diluc and Kaeya 题意 题目传送门 给你一个字符串 \(S\),其中只包含 'K' 或 'D' 两种字符,要求划分这个字符串使得各部分的 \(n(D):n(K)\) 相同,其中 \(n(D)\) 表示 \(S\) 中字符 'D' 出现的个数,最大化划分后形成的组数。 求 ......
codeforces刷题(1100):1901B_div2
挺好的一道裸区间贪心,非常基础。我刚开始写可能想的太复杂了(重复考虑了0的情况),不过看了题解恍然大悟,还是菜就多练。 ......
codeforces刷题(1100):1902B_div2
B、Getting Points 跳转原题点击此:该题地址 1、题目大意 Monocarp为了完成总共n天的某学期的p学分任务。Monocarp每天可以选择两种度过方式:上一次课和完成最多两个任务 或者 休息一天。其中上课获得l学分,每个任务获得t学分,其中任务不可以重复接取,并且每周获得一个新的任 ......
Pinely Round 3 (Div. 1 + Div. 2)
A. Distinct Buttons #include<bits/stdc++.h> using namespace std; void solve(){ int n; cin>>n; int a=0,b=0,c=0,d=0; for(int i=1;i<=n;i++){ int x,y; cin ......
「题解」Codeforces 1427G One Billion Shades of Grey
感谢 127 的指导/ll \(|h_u-h_v|=\max(0,h_u-h_v)+\max(0,h_v-h_u)\),那么可以把它看成这样的问题: \[\min \{\sum_{(u,v)}\max(0,h_u-h_v+w_{u,v})c_{u,v}\} \]对偶一下,问题就变为:如果两个格子相邻 ......
题解 P9993【[Ynoi Easy Round 2024] TEST_133】
就硬把 线段树 3 和 数列分块入门 2 揉到一起出。 维护原数组 \(a\) 及其历史最大值 \(hist\),对每个块,维护块内 \(a\) 升序排序后结果 \(p\)、块内 \(a\) 升序排序后历史最大值前缀和 \(prehist\)、块加标记 \(add\)、块历史和加标记 \(hista ......
codeforces刷题(1100):1904B_div2
B、Collecting Game 跳转原题点击此:该题地址 1、题目大意 获得一个由n位正整数组成的数组。你可以选择选择任意一个数作为你的判断值。然后任意一个 \(\le\) 它的数可以被选中加入你的分数(注意判断值不算在里面),同时该数被移除数组。你的任务是,对于该数组中的每个数,都将其作为判断 ......
LibreOJ#535. 「LibreOJ Round #6」花火
LibreOJ#535. 「LibreOJ Round #6」花火 \(n\) 个烟火排成一排,从左到右高度分别为 \(h_1,h_2,\cdots,h_n\),这些高度两两不同。 每次 Yoko 可以选择两个相邻的烟火交换,这样的交换可以进行任意多次。 每次 Yoko 还可以选择两个不相邻的烟火交 ......
CodeForces 1917E Construct Matrix
洛谷传送门 CF 传送门 \(2 \nmid k\) 显然无解。 若 \(4 \mid k\),发现给一个全 \(2 \times 2\) 子矩形全部异或 \(1\) 不会对行异或和和列异或和造成影响。那么我们找到 \(\frac{k}{4}\) 个全 \(0\) 的 \(2 \times 2\) ......
codeforces刷题(1100):1905B_div2
B、Begginer's Zelda 跳转原题点击此:此题地址 1、题目大意 给你一个子树,你可任意选择两个节点\(u、v\),这两个节点之间的所有节点(包括\(u、v\))都将结合变为一个新的节点。要求你通过该操作将所有的节点变为只有一个节点,求最小的操作数。 2、题目解析 由题意可得:当\(u、 ......
CodeForces 1917F Construct Tree
洛谷传送门 CF 传送门 考虑形式化地描述这个问题。先把 \(l\) 排序。然后相当于是否存在一个 \(\{1, 2, \ldots, n\}\) 的子集 \(S\),使得: \(\sum\limits_{i \in S} l_i = d\)。 \(\exists T \subseteq S, \m ......
Codeforces Round 915 (div2) E
E. Tree Queries [题目链接](https://codeforces.com/contest/1904/problem/EProblem - E - Codeforces) 题意概括: 给定一棵大小为 \(n\) 的树,回答如下询问,询问之间相互独立: 给定一个点 \(x\) 与 \( ......
codeforces刷题(1100):1917B_div2
模板 B、Erase First or Second Letter 跳转原题点击此:该题地址 1、题目大意 给你一个字符串,可以执行任意次以下操作,生成最终的字符串(不可为空),问你能生成的不重复字符串数为多少。 操作一:删除字符串第一个字符; 操作二:删除字符串第二个字符。 2、题目解析 发现,操 ......
Codeforces 1909G - Pumping Lemma
这个题思考角度很多,做法也很多。这里介绍一种 @asmend 和我讲的做法。 设 \(d=m-n\),那么我们枚举 \(|x|=i,|y|=j\),设 \(s,t\) 的 LCP 长为 \(l_1\),LCS 长为 \(l_2\),那么可以得到这组 \((i,j)\) 合法的充要条件是: \(i\l ......
Codeforces1917F - Construct Tree
Codeforces1917F - Construct Tree Problems 给一个长度为 \(n\) 的序列 \(l\) 和 \(d\)。 要求判断是否可以构造出一颗节点数为 \(n+1\) 的树,满足 \(l\) 的每一个元素唯一对应为一条边的长度,并使整棵树的直径长度恰好为 \(d\)。 ......
CodeForces 1906K Deck-Building Game
洛谷传送门 CF 传送门 UNR #2 黎明前的巧克力。 枚举两个人选的卡的并集 \(S\),那么当 \(\bigoplus\limits_{i \in S} a_i = 0\) 时 \(S\) 有贡献 \(2^{|S|}\)。 考虑将 \(2^{|S|}\) 分摊到每个元素上,也就是每个元素有 \ ......
Codeforces1917E - Construct Matrix
Codeforces1917E - Construct Matrix 首先考虑因为 \(n\) 为偶数,所以 \(k\) 为奇数时不可能满足条件。 其次,如果 \(4|k\),那么实际上在矩阵中一直放 \(2\times 2\) 的全为 \(1\) 的矩阵就可以了。 随后,如果 \(k \equiv ......
Codeforces Round 917 (Div. 2)
基本情况 A题秒了,B题卡了一年。 B. Erase First or Second Letter Problem - B - Codeforces 卡题分析 两方面原因 没有变通,一开始的思路是公式算出总字串数再想办法找重复的减掉,但搞了一个小时都不可行,应该早点换成正着来找的思路。 没有更深入的 ......
codeforces刷题(1100):1907C_div3
C、Removal of Unattractive Pairs 跳转原题点击此:[该题地址](Problem - 1907C - Codeforces) 1、题目大意 给定一个字符串,可以删除相邻的两个不相等的字符。问你删除后能得到最小的字符串长度为多少。 2、题目解析 因为只要两个不相等的字符相邻 ......
CF contest 1909 Pinely Round 3 (Div. 1 + Div. 2) 题解(Vanilla的掉分赛)
[Pinely Round 3 (Div. 1 + Div. 2) - Codeforces](https://codeforces.com/contest/1909)
$$
\color{purple}\large\textbf{世界上只有一种真正的英雄主义,}
$$
$$
\color{red}... ......
Pinely Round 3 (Div. 1 + Div. 2)
A 构造题,分两种情况考虑 上下都行,左右选一个 左右都行,上下选一个 void solve() { int n; cin >> n; vector<pair<int, int> > a(n); for(auto &t : a) cin >> t.x >> t.y; sort(a.begin(), ......
CodeForces 1909D Split Plus K
洛谷传送门 CF 传送门 设最后每个数都相等时为 \(t\)。那么一次操作变成了合并两个数 \(x, y\),再增加 \(x + y - k\)。于是每个 \(a_i\) 可以被表示成 \(b_i t - (b_i - 1)k\) 的形式,化简得 \(a_i - k = b_i (t - k)\)。 ......
CodeForces 1909E Multiple Lamps
洛谷传送门 CF 传送门 感觉这个题比较难蚌。 发现按 \(1 \sim n\) 最后可以把 \(1 \sim n\) 中的所有平方数点亮。所以 \(n \ge 20\) 就直接输出 \(1 \sim n\)。 考虑 \(n \le 19\)。猜测合法的方案(即按完后亮灯数 \(\le \left\ ......
CodeForces 1909F2 Small Permutation Problem (Hard Version)
洛谷传送门 CF 传送门 感觉这个题还是挺不错的。 考虑 F1。考察 \(a_i\) 差分后的意义,发现 \(a_i - a_{i - 1}\) 就是 \((\sum\limits_{j = 1}^{i - 1} [p_j = i]) + p_i \le i\)。 考虑将其转化为棋盘问题。在 \(( ......
Pinely Round 3 (Div. 1 + Div. 2) A~D
A. Distinct Buttons // #include <bits/stdc++.h> #include <iostream> #include <string> #include <cstring> #include <vector> #include <algorithm> #inclu ......
Pinely Round 3 (Div. 1 + Div. 2)
\(A.Distinct Buttons\) https://codeforces.com/contest/1909/submission/238508091 \(B.Make Almost Equal With Mod\) https://codeforces.com/contest/1909/s ......
Codeforces 1900E Transitive Graph
考虑题目的限制条件:存在 $a\to b, b\to c$ 的边,就会有 $a\to c$ 的边。 考虑 $p_{1\sim k}$,满足这 $k$ 个点按顺序组成了一个环且无重点。 那么 $p_1\to p_2, p_2\to p_3$,就有 $p_1\to p_3$,又有 $p_3\to p_4 ......
codeforces比赛(1):codeforces 916_div3
我的第一篇博客,虽然发布的都是非常简单的算法题,也没人看。我希望未来当我算法水平提高一个档次来看或许会有新的感受。这次cf比赛第一次写出来div3的D题,并且还剩余1小时,非常开心,一定继续保持下去。 ......