1797972105
文章
共 7 篇- 个人记录
CF Counting Problems
以下是 Codeforces 计数类题目(rating 1600–2200,contestId ≥ 1800)的简洁中文总结,按难度从高到低排序,并保留每道题的链接: 难度:2200(高难度) 2262C - Traveling the World 标签:combinatorics, constructive algorithms, graphs, greedy, math 链接:https://codeforces.com/problemset/problem/2262/C 2259H - Treasure Map Destruction (Counting Version) 标签:dfs and similar, dp, dsu, graphs, math 链接:https://codeforces.com/problemset/problem/2259/H 2254G - Nightcrawler 标签:data structures, dfs and similar, dp, greedy, sortings, trees 链接:https://codeforces.com/problemset/problem/2254/G 2242E - Product of Closures 标签:bitmasks, brute force, constructive algorithms, greedy, implementation, math, number theory 链接:https://codeforces.com/problemset/problem/2242/E 2239C - Revival 标签:binary search, data structures, math, two pointers 链接:https://codeforces.com/problemset/problem/2239/C 2236F2 - Elections in Saransk (hard version) 标签:combinatorics, dp, math, number theory 链接:https://codeforces.com/problemset/problem/2236/F2 2233E1 - Permutation Transmission (Easy Version) 标签:bitmasks, combinatorics, sortings 链接:https://codeforces.com/problemset/problem/2233/E1 2225E - Covering Points with Circles 标签:constructive algorithms, geometry, math 链接:https://codeforces.com/problemset/problem/2225/E 2209E - A Trivial String Problem 标签:brute force, dp, hashing, string suffix structures, strings 链接:https://codeforces.com/problemset/problem/2209/E 2207D - Boxed Like a Fish 标签:dfs and similar, dp, games, shortest paths, trees 链接:https://codeforces.com/problemset/problem/2207/D 难度:2100(中高难度) 2264E1 - A Prime Flood (Easy Version) 标签:combinatorics, dp, number theory 链接:https://codeforces.com/problemset/problem/2264/E1 2255C - Even If the World Turns 标签:communication, constructive algorithms, expression parsing, greedy, interactive, math, number theory 链接:https://codeforces.com/problemset/problem/2255/C 2252E - Generational Triplets 标签:bitmasks, combinatorics, dp, math 链接:https://codeforces.com/problemset/problem/2252/E 2234E - Vlad,
- 算法·理论
动态规划从入门到入坟
本文介绍了动态规划(dp)的基本概念与应用方法。首先,通过斐波那契数列的递归优化引出dp思想,指出两种常见实现方式:自顶向下的记忆化搜索(通过dp数组存储已计算结果)和自底向上的迭代计算(从基础状态逐步推导),两者时间复杂度均为O(n)。接着总结了dp的三大核心性质——最优子结构、重叠子问题和无后效性,并解释了相关术语如basecase、状态、状态转移方程等,强调状态设计与转移方程的关联性。 在基本类型部分,重点讲解了序列dp的典型应用场景,如最长递增子序列(状态定义为以第i个元素结尾的最长子序列长度)、任务安排问题(通过枚举分段点并结合贡献法计算最小费用)以及CF1067A数组填充问题(采用三维状态表示当前元素与前一个元素的大小关系)。文中还提到需根据题目特点选择填表法或刷表法,并建议读者通过例题练习和课后习题巩固知识,部分超纲题目可后续学习后再尝试。
- 个人记录
Solution
考虑一个数会被加多少次以及被减多少次。显然 A_i 会加 B 中小于 A_i 的元素的个数次,减 B 中大于 A_i 元素的个数次。 B_i 同理。 为了简化,我们先把相等的情况放在加里,即 B 中小于等于 A_i 的数的个数为加的次数。最后减去 相等的值*A中的个数*B中的个数…
- 题解
题解:CF2184D Unfair Game
该代码通过预计算组合数,统计满足特定条件的数的个数。对于给定的n和k,首先确定n的二进制位数d,然后遍历所有可能的位数i(从1到d-1)和对应的1的个数j,若i + j + 1 > k,则累加组合数C(i, j)。最后,若最高位的位数d + 1 > k,ans加1。最终输出满足条件的数的总数。
6 赞 - 题解
题解:AT_abc422_f Eat and Ride
动态规划。 发现性质:显然如果经过某一个点 u,去往另一个点 v,设两点间的距离为 i,则答案需要统计 i 次的 w_u。 状态定义:设 dp_x,i 表示 x 到终点还需要走 i 步的最小花费。 Base Case:由于我们从一号结点开始走,所以 forall i,dp_1,i…
- 题解
题解:P11138 [APC001] C - Not APC
该题解通过维护两个队列分别记录字符串中'A'和'P'的位置,利用线性扫描实现O(n)时间复杂度的匹配算法。当遇到字符'C'时,若存在未匹配的'A'和'P',则取出队列首部的'A'与'P'位置构成三元组(A索引,P索引,C索引)作为答案。最终输出未被匹配的字符或"Perfect",并输出所有匹配的三元组。核心思想是通过队列先进先出的特性,保证每个字符仅被处理一次,实现高效匹配。
1 赞 - 题解
题解:P11072 Alice and Bob
本题核心思路为:若初始区间[1,a₁]内包含0,则先手必胜;若不包含0,则先手必败。具体分析如下: 当a₁=0或先手无法操作时,后手获胜; 区间内存在0时,先手可直接获胜; 区间无0时,先手需通过改变a₁的值进行操作,若操作后a₁仍相同则必输,若操作导致区间出现0则同样触发条件1导致输掉。因此,初始无0时先手无法获胜。