04 2025 档案
摘要:题目链接:https://atcoder.jp/contests/abc159/tasks/abc159_f 解题思路: 枚举每个区间 \([i, j]\),在每个区间都进行背包计数。 示例程序: #include <bits/stdc++.h> using namespace std; const
阅读全文
摘要:题目链接:https://www.luogu.com.cn/problem/P2014 首先这题我们可以看成一个包含 \(n+1\) 个点(还有一个点是 \(0\) 号点,且定义 \(s_0 = 0\))。 每个节点 \(i\) 可以看成一个费用为 \(1\),价值为 \(s_i\) 的物品。 定义
阅读全文
摘要:题目链接:https://www.luogu.com.cn/problem/U558143 题目大意 老汪准备参加宋词大赛,他一共掌握 \(n\) 个 词牌名,并且他的宋词有 \(m\) 个不同的 主题。 为了方便描述,我们对词牌名从 \(1\) 到 \(n\) 编号,主题从 \(1\) 到 \(m
阅读全文
摘要:题目链接:https://www.luogu.com.cn/problem/P2365 题目大意: \(n\) 个任务排成一个序列在一台机器上等待完成(顺序不得改变),这 \(n\) 个任务被分成若干批,每批包含相邻的若干任务。 从零时刻开始,这些任务被分批加工,第 \(i\) 个任务单独完成所需的
阅读全文
摘要:题目链接:https://atcoder.jp/contests/abc403/tasks/abc403_g 解题思路: 每个节点额外维护两个信息: sum[1]:这个节点所在子树中所有 dfs序为奇数的节点的权值和; sum[0]:这个节点所在子树中所有 dfs序为偶数的节点的权值和。 使用 FH
阅读全文
摘要:题目链接:https://atcoder.jp/contests/arc030/tasks/arc030_4 题目大意:vjudge链接 现有一个长度为 \(N\) 的数列 \(X={x_1,x_2,...,x_N}\)。需要对数列执行 \(Q\) 次查询操作。查询操作共有\(3\) 种类型,具体如
阅读全文
摘要:题目链接:https://www.luogu.com.cn/problem/P3379 解题思路: 对一棵树进行 DFS,无论是第一次访问还是回溯,每次到达一个结点时都将编号记录下来,可以得到一个长度为 \(2n-1\) 的序列,这个序列被称作这棵树的欧拉序列。 在下文中,把结点 u 在欧拉序列中第
阅读全文
摘要:题目链接:https://www.luogu.com.cn/problem/P1533 解题思路: 主席树求区间第k小模板题 示例程序: #include <bits/stdc++.h> using namespace std; const int maxn = 1e7 + 5; const int
阅读全文
摘要:题目链接:https://www.luogu.com.cn/problem/P3466 解题思路完全来自 CodyTheWolf大佬的博客 示例程序: #include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; mt
阅读全文
摘要:题目链接:https://www.luogu.com.cn/problem/P2161 题目大意: 你需要维护一个在数轴上的线段的集合 \(S\),支持两种操作: A l r 表示将 \(S\) 中所有与线段 \([l,r]\) 相交的线段删去,并将 \([l,r]\) 加入 \(S\) 中。 B
阅读全文
摘要:题目链接:https://www.luogu.com.cn/problem/P3871 解题思路: FHQ Treap模板题,只涉及插入和 kth 操作。 示例程序: #include <bits/stdc++.h> using namespace std; const int maxn = 2e5
阅读全文
摘要:题目链接:https://www.acwing.com/problem/content/2439/ 解题思路: 翻转,加懒惰标记 示例程序: #include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; mt19937
阅读全文
摘要:题目链接:https://www.luogu.com.cn/problem/P3369 FHQ Treap 示例程序: #include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; mt19937 rng(time(0
阅读全文
摘要:题目链接:https://atcoder.jp/contests/abc400/tasks/abc400_d 解题思路: 双端队列BFS(0-1 BFS)参考资料:https://oi.wiki/graph/bfs/#双端队列-bfs 比赛时我是用SPFA写的,然后TLE了一个点,然后用dijkst
阅读全文
摘要:题目链接:https://atcoder.jp/contests/arc084/tasks/arc084_b 题目大意: 找到一个数位和最小的整数,这个整数是 \(K(\le 10^5)\) 的倍数,输出数位和。 解题思路: 观察到任意一个正整数都可以从 \(1\) 开始,按照某种顺序执行乘 \(1
阅读全文
摘要:题目链接:https://www.luogu.com.cn/problem/P2371 参考博客: oi wiki https://oi-wiki.org/graph/mod-shortest-path/ xht大佬的博客 https://www.luogu.com.cn/article/tgfwb
阅读全文
摘要:题目链接:https://www.luogu.com.cn/problem/P3403 参考博客: oi wiki https://oi-wiki.org/graph/mod-shortest-path/ xht大佬的博客 https://www.luogu.com.cn/article/tgfwb
阅读全文
摘要:题目链接:https://codeforces.com/problemset/problem/1473/E dis[u][c1][c2] 表示到达顶点 \(u\) 有无经过最短边(\(c1\) 标记)有无经过最长边(\(c2\) 标记)时的最短路。 示例程序: #include <bits/stdc
阅读全文
浙公网安备 33010602011771号