随笔分类 -  codeforces

摘要:题目描述 给定一棵大小为 \(n\) 的 \(1\) 为根节点的树,树用如下方式给出:输入 \(a_2,a_3,\dots,a_n\),保证 \(1\leq a_i<i\),将 \(a_i\) 与 \(i\) 连边形成一棵树。 接下来有 \(m\) 次操作,操作有两种: 1 l r x 令 \(a_ 阅读全文
posted @ 2023-12-21 14:38 灰鲭鲨 阅读(26) 评论(0) 推荐(0)
摘要:A Perfect Problem 题面翻译 一个序列是好的当且仅当集合最大值乘上集合最小值大于等于集合元素的加和; 一个序列是完美的,当且仅当这个序列的任何子序列都是好的(包括自己不包括空集); 你要求的是:长度为 \(n\) 的并且每一个元素都大于等于 \(1\) 并且小于等于 \(n+1\) 阅读全文
posted @ 2023-12-12 15:56 灰鲭鲨 阅读(69) 评论(0) 推荐(0)
摘要:Cheap Robot 题面翻译 给你一张 \(N\) 个点的带权无向连通图,其中结点 \(1,2,…,k\) 为充电中心。 一个机器人在图中行走,假设机器人的电池容量为 \(c\),则任何时刻,机器人的电量 \(x\) 都必须满足 \(0\le x\le c\)。如果机器人沿着一条边权为 \(w\ 阅读全文
posted @ 2023-12-12 12:59 灰鲭鲨 阅读(96) 评论(0) 推荐(0)
摘要:题目链接 树的情况不好做。先树剖,现在变成了链的问题。 考虑对时间扫描线,会发现所有人的相对顺序变化的时候,就是有人相遇了。所以他的相对顺序可以用一个 set 维护。而将会相遇的人一定是插入时相对顺序相邻的人,可以 check 一下取个最小值。可以把时间线设成全局变量,这样就可以跑 set 的排序了 阅读全文
posted @ 2023-12-11 22:37 灰鲭鲨 阅读(27) 评论(0) 推荐(0)
摘要:题目链接 操作 2 和 3 可以用另两个代替,没有任何用。 设 W 表示 \(t_{i,j}=0\),B 表示 \(t_{i,j}=1\) 考虑差分。设 \(t_{i,j}=s_{i,j}\oplus s_{i+1,j}\oplus s_{i,j+1}\oplus s_{i+1,j+1}\),那么目 阅读全文
posted @ 2023-12-11 20:57 灰鲭鲨 阅读(27) 评论(0) 推荐(0)
摘要:题目链接 如果把方向看做有向边,整个图是一个内向基环树。 所以考虑哪些点有可能放在基环树的非环部分上,当且仅当一个点周围有严格小于他的点。 由于图一定是二分图(黑白染色),没有奇环,所有偶环一定可以拆成二元环,所以可以看做找匹配。两个点能匹配当且仅当他们 \(s\) 相等。 发现一个周围没有严格小于 阅读全文
posted @ 2023-12-11 20:40 灰鲭鲨 阅读(37) 评论(0) 推荐(0)
摘要:题目描述 Archaeologists found some information about an ancient land of Treeland. We know for sure that the Treeland consisted of $ n $ cities connected b 阅读全文
posted @ 2023-10-30 21:39 灰鲭鲨 阅读(41) 评论(0) 推荐(0)
摘要:Two Rooted Trees 题面翻译 题目描述 你有两棵有根树,每棵树都有 \(n\) 个结点。不妨将这两棵树上的点都用 \(1\) 到 \(n\) 之间的整数编号。每棵树的根结点都是 \(1\)。第一棵树上的边都是蓝色,第二课树上的边都是红色。我们也称第一棵树是蓝色的,第二棵树是红色的。 对 阅读全文
posted @ 2023-10-30 20:57 灰鲭鲨 阅读(15) 评论(0) 推荐(0)
摘要:And Reachability 题面翻译 题目描述 Toad Pimple 有一个整数数组 \(a_1,\dots,a_n\)。 当 \(x < y\) 且存在 \(x = p_1 < \dots < p_k = y\) 的数列 \(p\) 满足 \(a_{p_i} \& a_{p_{i+1}} 阅读全文
posted @ 2023-10-17 20:33 灰鲭鲨 阅读(23) 评论(0) 推荐(0)
摘要:题目描述 Note that the memory limit in this problem is less than usual. Let's consider an array consisting of positive integers, some positions of which c 阅读全文
posted @ 2023-10-09 11:27 灰鲭鲨 阅读(18) 评论(0) 推荐(0)
摘要:题目描述 Rishi is developing games in the 2D metaverse and wants to offer game bundles to his customers. Each game has an associated enjoyment value. A ga 阅读全文
posted @ 2023-10-04 21:09 灰鲭鲨 阅读(27) 评论(0) 推荐(0)
摘要:题目描述 You're going to generate an array $ a $ with a length of at most $ n $ , where each $ a_{i} $ equals either $ 1 $ or $ -1 $ . You generate this a 阅读全文
posted @ 2023-09-25 11:37 灰鲭鲨 阅读(42) 评论(0) 推荐(0)
摘要:题目描述 Steve Rogers is fascinated with new vibranium shields S.H.I.E.L.D gave him. They're all uncolored. There are $ n $ shields in total, the $ i $ -t 阅读全文
posted @ 2023-09-25 11:22 灰鲭鲨 阅读(27) 评论(0) 推荐(0)
摘要:This is a harder version of the problem. In this version, \(n \le 7\).Marek is working hard on creating strong test cases to his new algorithmic probl 阅读全文
posted @ 2023-09-22 20:35 灰鲭鲨 阅读(122) 评论(0) 推荐(0)
摘要:题目描述 This is the hard version of this problem. The only difference is the limit of $ n $ - the length of the input string. In this version, $ 1 \leq n 阅读全文
posted @ 2023-09-17 21:07 灰鲭鲨 阅读(32) 评论(0) 推荐(0)
摘要:## 题目描述 Sam changed his school and on the first biology lesson he got a very interesting task about genes. You are given $ n $ arrays, the $ i $ -th o 阅读全文
posted @ 2023-09-04 16:45 灰鲭鲨 阅读(25) 评论(0) 推荐(0)
摘要:## 题目描述 On a permutation $ p $ of length $ n $ , we define a bully swap as follows: - Let $ i $ be the index of the largest element $ p_i $ such that 阅读全文
posted @ 2023-09-04 16:31 灰鲭鲨 阅读(54) 评论(0) 推荐(0)
摘要:## 题目描述 You are given an array $ A $ of length $ N $ weights of masses $ A_1 $ , $ A_2 $ ... $ A_N $ . No two weights have the same mass. You can put 阅读全文
posted @ 2023-09-04 16:03 灰鲭鲨 阅读(51) 评论(0) 推荐(0)
摘要:## 题目描述 You are given a tree with $ n $ nodes. For each node, you either color it in $ 0 $ or $ 1 $ . The value of a path $ (u,v) $ is equal to the ME 阅读全文
posted @ 2023-09-04 15:53 灰鲭鲨 阅读(37) 评论(0) 推荐(0)
摘要:## 题目描述 Michael and Brian are stuck in a hotel with $ n $ rooms, numbered from $ 1 $ to $ n $ , and need to find each other. But this hotel's doors ar 阅读全文
posted @ 2023-09-04 15:31 灰鲭鲨 阅读(19) 评论(0) 推荐(0)