Stay Hungry,Stay Foolish!

上一页 1 2 3 4 5 6 7 8 ··· 21 下一页
摘要: D - Writing a Numeral https://atcoder.jp/contests/abc298/tasks/abc298_d 思路 双端队列, 保证执行插入和删除动作的同时, 动态计算 结果。 模运算 https://www.cnblogs.com/wlw-x/p/11735614 阅读全文
posted @ 2023-04-15 23:45 lightsong 阅读(64) 评论(0) 推荐(0) 编辑
摘要: D. Connected Components https://www.codeforces.com/contest/292/problem/D 思路 由于需要删除任意 连续段的 连接线, 引入前缀和 连续段的左右两边都需要, 所以引入两个前缀和。 https://blog.csdn.net/qq_ 阅读全文
posted @ 2023-04-15 11:33 lightsong 阅读(15) 评论(0) 推荐(0) 编辑
摘要: B. Two Sets https://codeforces.com/problemset/problem/468/B 思路 对于每个元素,计算其集合归属性, 但是要注意的是, x, a-x 如果都存在, 并不意味着他们只能出现在A集合中 特殊情况下, 也可以出现的B集合 b-x x a-x b-( 阅读全文
posted @ 2023-04-14 17:03 lightsong 阅读(10) 评论(0) 推荐(0) 编辑
摘要: E - Kth Takoyaki Set https://atcoder.jp/contests/abc297/tasks/abc297_e 思路 使用优先队列,从0 开始, 对所有可能的扩展,计算累加和, 添加到队列, 每次从队列取出最小值,直到取出第k个。 Code #include <ioma 阅读全文
posted @ 2023-04-09 22:13 lightsong 阅读(66) 评论(0) 推荐(0) 编辑
摘要: D - Count Subtractions https://atcoder.jp/contests/abc297/tasks/abc297_d 思路 按照题目给的逻辑会超时。 需要使用 除法来优化算法。 Code #include <iomanip> #include <bits/stdc++.h 阅读全文
posted @ 2023-04-09 22:10 lightsong 阅读(20) 评论(0) 推荐(0) 编辑
摘要: E - Transition Game https://atcoder.jp/contests/abc296/tasks/abc296_e 思路 Code https://atcoder.jp/contests/abc296/submissions/40262511 #include <bits/s 阅读全文
posted @ 2023-04-03 22:11 lightsong 阅读(21) 评论(0) 推荐(0) 编辑
摘要: C - Gap Existence https://atcoder.jp/contests/abc296/tasks/abc296_c 思路 非常规比对。 对于每个元素, 计算其 + x 和 -x 情况, 计算之后的值,如果也在当前列表中, 则满足要求。 Code https://atcoder.j 阅读全文
posted @ 2023-04-02 22:29 lightsong 阅读(16) 评论(0) 推荐(0) 编辑
摘要: D - M<=ab https://atcoder.jp/contests/abc296/tasks/abc296_d 思路 a 和 b 的范围都是 1 到 n, a 和 b 在大小关系上是对称的, 我们只考虑 a < b 的情况, 同时 a 也可以 等于 b 所以我们考虑 a <= b 情况 又 阅读全文
posted @ 2023-04-02 22:25 lightsong 阅读(111) 评论(0) 推荐(0) 编辑
摘要: D - Bank https://atcoder.jp/contests/abc294/tasks/abc294_d 思路 准备一个优先队列wait,用于所有取钱者的排队,按照ID从小到大排队; 准备一个集合called,用于存储所有已经被叫到号的取钱者; 每次teller叫号后,将叫到号的取钱者放 阅读全文
posted @ 2023-03-27 21:49 lightsong 阅读(17) 评论(0) 推荐(0) 编辑
摘要: E - Geometric Progression https://atcoder.jp/contests/abc293/tasks/abc293_e 思路 根据矩阵递推式 找出转移矩阵的幂形式。 利用矩阵快速幂计算。 Code https://atcoder.jp/contests/abc293/ 阅读全文
posted @ 2023-03-22 22:02 lightsong 阅读(31) 评论(0) 推荐(0) 编辑
摘要: C - Merge Sequences https://atcoder.jp/contests/abc294/tasks/abc294_c 思路 归并排序思想。 Code https://atcoder.jp/contests/abc294/submissions/39930476 #include 阅读全文
posted @ 2023-03-21 22:07 lightsong 阅读(10) 评论(0) 推荐(0) 编辑
摘要: D - Tying Rope https://atcoder.jp/contests/abc293/tasks/abc293_d 思路 /* one rope model: one end color -- rope number -- another end color short form: c 阅读全文
posted @ 2023-03-16 21:11 lightsong 阅读(11) 评论(0) 推荐(0) 编辑
摘要: C - Make Takahashi Happy https://atcoder.jp/contests/abc293/tasks/abc293_c 思路 回溯遍历算法, dfs从1,1位置开始遍历,把所有可能分支都跑遍, 统计总的数目。 Code https://atcoder.jp/contes 阅读全文
posted @ 2023-03-13 09:30 lightsong 阅读(41) 评论(0) 推荐(0) 编辑
摘要: A. Plant https://codeforces.com/contest/185/problem/A 思路 发现状态转移矩阵M 目标状态-上三角 目标状态-下三角 源状态-上三角 3 1 源状态-下三角 1 3 初始状态为向量V 初始状态-上三角 1 初始状态-下三角 0 过第一年V的转变为 阅读全文
posted @ 2023-03-13 09:21 lightsong 阅读(20) 评论(0) 推荐(0) 编辑
摘要: P1551 亲戚 https://www.luogu.com.cn/problem/P1551 思路 并查集统计亲戚集合。 Code https://www.luogu.com.cn/record/104070571 #include <iomanip> #include <bits/stdc++. 阅读全文
posted @ 2023-03-08 22:27 lightsong 阅读(17) 评论(0) 推荐(0) 编辑
摘要: E - Transitivity https://atcoder.jp/contests/abc292/tasks/abc292_e 思路 https://blog.csdn.net/a1845613403/article/details/129343684 记录每个点的入节点集合, 和 出节点集合 阅读全文
posted @ 2023-03-08 22:23 lightsong 阅读(19) 评论(0) 推荐(0) 编辑
摘要: Sorting It All Out http://poj.org/problem?id=1094 思路 每加入一条边需要进行一次拓扑排序,如果拓扑排序发现有环,或者排序唯一那么就可以直接输出结果,如果所有的边输入完成还不是上述两种情况,那就输出不能判断。 这里的重点在于如何判断拓扑排序的唯一性 判 阅读全文
posted @ 2023-03-06 00:34 lightsong 阅读(19) 评论(0) 推荐(0) 编辑
摘要: D - Redistribution https://atcoder.jp/contests/abc178/tasks/abc178_d 思路 设f[i]:表示用3~i数凑出和为i的方案数 f[i]=f[i-3]+f[i-4]+f[i-5]+…+f[i-i] https://blog.csdn.ne 阅读全文
posted @ 2023-03-05 22:35 lightsong 阅读(14) 评论(0) 推荐(0) 编辑
摘要: 1009. K-based Numbers https://acm.timus.ru/problem.aspx?space=1&num=1009 思路 典型dp问题 对于n位k位底的数, 求不存在连续0出现的数目。 设f(i) 为 i位,最后一位为不为0的数目 设g(i)为i位,最后一位为0的数目 阅读全文
posted @ 2023-03-05 22:31 lightsong 阅读(13) 评论(0) 推荐(0) 编辑
摘要: D - Unicyclic Components https://atcoder.jp/contests/abc292/tasks/abc292_d 思路 并查集,统计连通子图, 并记录edges 数 和 vertices数。 CANKAO: https://blog.csdn.net/karry_ 阅读全文
posted @ 2023-03-04 22:38 lightsong 阅读(40) 评论(0) 推荐(0) 编辑
摘要: P1983 [NOIP2013 普及组] 车站分级 https://www.luogu.com.cn/problem/P1983 思路 https://www.cnblogs.com/tomori/p/14331510.html Code https://www.luogu.com.cn/recor 阅读全文
posted @ 2023-03-03 12:41 lightsong 阅读(23) 评论(0) 推荐(0) 编辑
摘要: C. Fox And Names https://codeforces.com/problemset/problem/510/C 思路 使用拓扑序算法,找出前后的依赖的可能情况。 如果拓扑序未找到所有的节点,表明存在依赖环,这种情况不满足。 Code https://codeforces.com/p 阅读全文
posted @ 2023-03-01 10:25 lightsong 阅读(15) 评论(0) 推荐(0) 编辑
摘要: E - Make it Palindrome https://atcoder.jp/contests/abc290/tasks/abc290_e 思路 参考: https://zhuanlan.zhihu.com/p/608325900 双指针部分,添加解释: Code https://zhuanl 阅读全文
posted @ 2023-03-01 00:03 lightsong 阅读(34) 评论(0) 推荐(0) 编辑
摘要: E - Find Permutation https://atcoder.jp/contests/abc291/tasks/abc291_e 思路 对于能唯一确定的情况,必然存在一个升序 路径 AX1 < AX2 < .... < AXn *** 如果有两个及以上入度为0的起点, 则这两点的先后关系 阅读全文
posted @ 2023-02-27 22:04 lightsong 阅读(37) 评论(0) 推荐(0) 编辑
摘要: G - Longest Path https://atcoder.jp/contests/dp/tasks/dp_g 思路 使用拓扑序, 依此从入度为0的节点开始, 向外扩展,直至只剩一个节点 扩展的过程中,对每个点的最大路径做记录。 Code https://atcoder.jp/contests 阅读全文
posted @ 2023-02-27 21:53 lightsong 阅读(19) 评论(0) 推荐(0) 编辑
摘要: D - Flip Cards https://atcoder.jp/contests/abc291/tasks/abc291_d 思路 动态规划思想 初始设置, 表示第一个位置, a 和 b各有一种选择 an[1] = 1 bn[1] = 1 后面使用递推式: an[i] += an[i-1] if 阅读全文
posted @ 2023-02-26 22:54 lightsong 阅读(68) 评论(0) 推荐(0) 编辑
摘要: D - Marking https://atcoder.jp/contests/abc290/tasks/abc290_d 思路 https://zhuanlan.zhihu.com/p/607818729 x即为最小循环节的长度 即经过x次mark, mark的位置又回到了 0 位置。 如下为x最 阅读全文
posted @ 2023-02-26 17:50 lightsong 阅读(27) 评论(0) 推荐(1) 编辑
摘要: D. Mouse Hunt https://codeforces.com/problemset/problem/1027/D 思路 考察ssc检测算法 每个宿舍对应下图中一个点, 由于老鼠从每个宿舍出发,只能到达一个宿舍, 则有向图中存在的 强连通子图 只可能是环,如下图 在检测出的强连通子图中, 阅读全文
posted @ 2023-02-21 21:21 lightsong 阅读(12) 评论(0) 推荐(0) 编辑
摘要: Popular Cows http://poj.org/problem?id=2186 思路 涉及到有向图的强连通子图检测,参考: https://oi-wiki.org/graph/scc/ https://www.cnblogs.com/zwfymqz/p/6693881.html 检测出每个强 阅读全文
posted @ 2023-02-20 22:47 lightsong 阅读(20) 评论(0) 推荐(0) 编辑
摘要: E - Swap Places https://atcoder.jp/contests/abc289/tasks/abc289_e 思路 T 从 1 要到 4 A 从 4 要到 1 两人同步移动 每次移动到的目标节点,花色要求不同。 设置系统i时刻所处的位置为 <Ti, Ai> 系统agent是在一 阅读全文
posted @ 2023-02-17 23:11 lightsong 阅读(36) 评论(0) 推荐(0) 编辑
摘要: E - Dividing Chocolate https://atcoder.jp/contests/abc159/tasks/abc159_e 思路 对于不大于k位置的查找, 前一篇给出了基于前缀和的 从左向右逐步查找方法 https://www.cnblogs.com/lightsong/p/1 阅读全文
posted @ 2023-02-16 21:47 lightsong 阅读(25) 评论(0) 推荐(0) 编辑
摘要: E - Dividing Chocolate https://atcoder.jp/contests/abc159/tasks/abc159_e 思路 https://www.cnblogs.com/ycx-akioi/p/AtCoder-abc159.html 行数少,列数多, 对行应用组合方法, 阅读全文
posted @ 2023-02-15 21:48 lightsong 阅读(17) 评论(0) 推荐(0) 编辑
摘要: D - Step Up Robot https://atcoder.jp/contests/abc289/tasks/abc289_d 思路 - 1 DFS 从0开始, 否则运用所有可能步子,检查新的位置点, 遇到block返回false, 是目标点x返回true Code - 1 DFS http 阅读全文
posted @ 2023-02-11 22:32 lightsong 阅读(27) 评论(0) 推荐(0) 编辑
摘要: C - Coverage https://atcoder.jp/contests/abc289/tasks/abc289_c 思路 对所有组合,依此遍历 判断组合内所有的集合是否覆盖 1...n 判断过程中,如果发现某个数不能被覆盖,则说明此组合不满足要求, 如果满足要求,计数加1 Code htt 阅读全文
posted @ 2023-02-11 22:24 lightsong 阅读(48) 评论(0) 推荐(0) 编辑
摘要: P1015 [NOIP1999 普及组] 回文数 https://www.luogu.com.cn/problem/P1015 思路 将字符串m转换为10进制的值 翻转m,也转换为10进制值, 后运用10进制加这两个数 转换为对应进制n的字符串, 判断是否为回文 Code -- Partial AC 阅读全文
posted @ 2023-02-11 15:55 lightsong 阅读(71) 评论(0) 推荐(0) 编辑
摘要: A. One and Two https://codeforces.com/problemset/problem/1788/A 思路 统计2的个数, 如果是奇数个, 不满足 如果是偶数个, 2队列中,前半部分最后一个2则为目标位置 如果个数是0, 即都是1的情况, 则k=1 Code https:/ 阅读全文
posted @ 2023-02-11 11:05 lightsong 阅读(14) 评论(0) 推荐(0) 编辑
摘要: B. Sum of Two Numbers https://codeforces.com/problemset/problem/1788/B 思路 计算原数的所有位置上的digit和 得到digit和的一半 对于原数从左到右切分,前半部分digit和为half 例如: 1331 -->> 1300 阅读全文
posted @ 2023-02-11 11:01 lightsong 阅读(30) 评论(0) 推荐(0) 编辑
摘要: P1002 [NOIP2002 普及组] 过河卒 https://www.luogu.com.cn/problem/P1002 思路 初始设置 0 行 0列的点 取值为1,表示有一条路径到达此目标点, 注意当遇到第一个障碍点, 停止赋值 然后对 1-n 行 1-m列 做dp计算 按照如下公式: dp 阅读全文
posted @ 2023-02-10 18:21 lightsong 阅读(31) 评论(0) 推荐(0) 编辑
摘要: B. Solitaire https://codeforces.com/problemset/problem/208/B 思路 dfs+回溯 对两种操作情况进行 地毯式搜索, 找到可能的一种方法。 Note: 需要使用cache对已经搜索过的路径的结果,做记录, 减少重复计算。参考: https:/ 阅读全文
posted @ 2023-02-10 00:05 lightsong 阅读(14) 评论(0) 推荐(0) 编辑
摘要: D - Pair of Balls https://atcoder.jp/contests/abc216/tasks/abc216_d 思路 m个桶, n个颜色, 第一轮遍历所有桶的最上面球的颜色, 将相同颜色的球所在队列, 计入 color节点, 即是说,存在两个桶的最上面的两个球颜色相同, 例如 阅读全文
posted @ 2023-02-08 22:26 lightsong 阅读(17) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 21 下一页
Life Is Short, We Need Ship To Travel