摘要: ![20250819-110602](https://img2024.cnblogs.com/blog/1972953/202508/1972953-20250819110612963-1182114203.jpg) 阅读全文
posted @ 2025-08-19 11:06 naymi 阅读(8) 评论(0) 推荐(0)
摘要: 参考 https://github.com/OneSizeFitsQuorum/cs-self-learning/blob/master/docs/ 6/2 MakeFile https://seisman.github.io/how-to-write-makefile/overview.html 阅读全文
posted @ 2022-06-02 16:13 naymi 阅读(111) 评论(0) 推荐(0)
摘要: https://acm.hdu.edu.cn/showproblem.php?pid=7068 对于一个数,最大得分时要加上b[1],最小得分加上b[n]. 寻找最大排名,要对每个b[2->n]匹配一个a[y],使尽可能多的和小于b[1] + a[x] 显然从小到大枚举b[i],依次在a中找即可 c 阅读全文
posted @ 2021-08-17 20:41 naymi 阅读(95) 评论(0) 推荐(0)
摘要: https://acm.hdu.edu.cn/showproblem.php?pid=7072 deque 模拟下每次加入数删除数即可,记录数是否被删除,数在左que还是右que,que中没被删除的数的个数 const int maxn = 2e7 + 7; int n, t, m, x, sizl 阅读全文
posted @ 2021-08-17 20:34 naymi 阅读(61) 评论(0) 推荐(0)
摘要: https://acm.hdu.edu.cn/showproblem.php?pid=7067 分情况讨论,k=1,k为奇数,k为偶数 特判第一个人直接不玩的情况即可 const int maxn = 1e5 + 7; #define int long long int n, t, m, k; ve 阅读全文
posted @ 2021-08-17 19:40 naymi 阅读(39) 评论(0) 推荐(0)
摘要: https://codeforces.com/contest/1506/problem/G 用单调栈维护拿的字母即可 const int maxn = 1e3 + 7; int n, t, m, cnt[300]; string s; void solve() { cin >> t; while ( 阅读全文
posted @ 2021-08-17 19:37 naymi 阅读(39) 评论(0) 推荐(0)
摘要: https://acm.hdu.edu.cn/showproblem.php?pid=7064 注意开数组的大小 注意优化(插入的时候判断长度是否可行) const int maxn = 1e5 + 7; int n, t, m, stp = 30; int nex[maxn * 33][27], 阅读全文
posted @ 2021-08-12 20:47 naymi 阅读(127) 评论(1) 推荐(0)
摘要: https://acm.hdu.edu.cn/showproblem.php?pid=7059 可以将每段区间的和转换成最高位的和+其他位的和. 查询 sum = lsum + rsum 减: 每个节点最多有三十次减操作,类似sqrt那个题目,直接在l==r的时候单点修改,注意需要判断当前能否减的条 阅读全文
posted @ 2021-08-12 20:38 naymi 阅读(73) 评论(0) 推荐(0)
摘要: 区间修改 #define int long long const int maxn = 3e5 + 7; int a[maxn]; struct node { int l, r, sum, lz; } tr[maxn << 4]; void push_up(int p) { tr[p].sum = 阅读全文
posted @ 2021-08-11 18:55 naymi 阅读(32) 评论(0) 推荐(0)
摘要: https://www.luogu.com.cn/problem/P3674 a - b = x 可以转换成 a = b + x.用bitset记录区间数的种类,存在a - b = x 等价于 bitset & bitset<<x 是否有1 a + b = x 可以记b = N - B,也就是判断 阅读全文
posted @ 2021-08-11 16:03 naymi 阅读(57) 评论(0) 推荐(0)
摘要: https://acm.hdu.edu.cn/showproblem.php?pid=7055 ##思路1 考虑dp结果,dp[i]表示以i为结尾的答案 每次新进入一个字符,计算其对答案产生的贡献 char s[maxn]; int t, cnt[30], sum[30]; ll dp[maxn]; 阅读全文
posted @ 2021-08-10 21:35 naymi 阅读(146) 评论(1) 推荐(0)
摘要: https://codeforces.com/contest/1557/problem/D 线段树维护dp + dp路径记录 + 离散化 考虑最多能保留的个数,线段树维护相邻两层间转移的1的位置的最大值. 对每层考虑,新加进来一个线段,都会产生一个非负的贡献,每次转移都要询问这一层能向上转移的每个点 阅读全文
posted @ 2021-08-10 21:16 naymi 阅读(53) 评论(0) 推荐(0)
摘要: https://ac.nowcoder.com/acm/contest/11259/F 用bitset滚动记录每个点能到达的其他点.暴力,n4/32 每次转移的时候. 如果这个点是'0', 如果右边点为'0', 就|=右边点能到达的点 如果右边点为'1'... 如果这个点为'1' reset这个点( 阅读全文
posted @ 2021-08-09 22:34 naymi 阅读(77) 评论(0) 推荐(0)
摘要: 莫队 普通莫队 注意顺序正确!! codes for (int i = 1; i <= m; i++) { int pl = q[i].l, pr = q[i].r; while (l > pl) add(a[--l]); while (r < pr) add(a[++r]); while (l < 阅读全文
posted @ 2021-08-09 20:13 naymi 阅读(29) 评论(0) 推荐(0)
摘要: https://ac.nowcoder.com/acm/contest/11258/F 对两颗树分别考虑. 对于第一颗树,考虑对每条链上双指针选择连续的节点(显然只有在同一条链上的点才能互为),用deque维护方便 对于第二颗树,n个点选择k个点互不为祖先,可以树剖+线段树维护,每次选择一个节点后对 阅读全文
posted @ 2021-08-07 20:28 naymi 阅读(124) 评论(3) 推荐(0)
摘要: https://codeforces.com/contest/1555/problem/E 比赛中板子错了 心态炸裂 (比正解多了个二分 对了也是tle 但是 显然可以不用二分 直接双指针瞎搞,按区间长度排序,双指针r就+1,l就-1. const int maxn = 1e6 + 7; int n 阅读全文
posted @ 2021-08-06 22:02 naymi 阅读(31) 评论(0) 推荐(0)
摘要: https://acm.hdu.edu.cn/showproblem.php?pid=6998 考虑每次操作能对答案产生的影响 记每次操作为$swap(a,b)$,dp[i]表示答案,初始化位-1表示状态不可达,开始时dp[k] = 0. a不可达 b可达 dp[v] = dp[u], dp[u] 阅读全文
posted @ 2021-08-06 21:58 naymi 阅读(96) 评论(0) 推荐(0)
摘要: https://codeforces.ml/contest/1469/problem/D 显然,容易构造n+20步完成.而在多出5步的情况下考虑每次保留sqrt(n) 按照下面进行构造: \([1,2,3,4,5,6,7,8,9] to [1,2,3,1,1,1,1,1,9] to [1,2,3,1 阅读全文
posted @ 2021-08-06 21:41 naymi 阅读(38) 评论(0) 推荐(0)
摘要: https://codeforces.com/contest/1168/problem/C 考虑$dp$,$dp[i][j]$表示从i开始最先到达的第j位为1的位置 如果$a[x]$能转移到$a[y]$那么必定有一位二进制位置上,\(dp[x][k]<=y\) $dp$转移:从$n$向$1$枚举$i 阅读全文
posted @ 2021-08-06 21:33 naymi 阅读(34) 评论(0) 推荐(0)
摘要: https://codeforces.com/contest/1313/problem/C2 单调栈维护下每个位置向前向后单调的最大和 const int maxn = 5e5 + 7; #define int long long int n, t, m; int a[maxn], pre[maxn 阅读全文
posted @ 2021-08-06 21:31 naymi 阅读(22) 评论(0) 推荐(0)
摘要: #bitmasks https://codeforces.com/contest/1469/problem/E https://codeforces.com/contest/1168/problem/C 考虑$dp$,$dp[i][j]$表示从i开始最先到达的第j位为1的位置 如果$a[x]$能转移 阅读全文
posted @ 2021-08-06 21:22 naymi 阅读(23) 评论(0) 推荐(0)
摘要: 构造 位运算构造 ?? 平方构造 https://codeforces.ml/contest/1469/problem/D 阅读全文
posted @ 2021-08-05 22:40 naymi 阅读(29) 评论(0) 推荐(0)
摘要: 树链剖分 + 线段树 模板 const int maxn = 1e5 + 7; #define ls(x) (x << 1) #define rs(x) (x << 1 | 1) int n, t, m, w[maxn]; vector<int> mp[maxn]; string op; int c 阅读全文
posted @ 2021-08-04 00:20 naymi 阅读(32) 评论(0) 推荐(0)
摘要: 百度之星2021 初试1 https://acm.hdu.edu.cn/showproblem.php?pid=6998 const int maxn = 1e6 + 7; int n, t, m, k; int dp[maxn]; void solve() { cin >> t; while (t 阅读全文
posted @ 2021-08-02 22:03 naymi 阅读(27) 评论(0) 推荐(0)
摘要: Educational Codeforces Round 112 (Rated for Div. 2) E: 双指针 + 线段树 比赛中板子错了 心态炸裂 (比正解多了个二分 对了也是tle 但是 显然可以不用二分 直接双指针瞎搞 const int maxn = 1e6 + 7; int n, t 阅读全文
posted @ 2021-07-31 09:43 naymi 阅读(40) 评论(0) 推荐(0)
摘要: 字典树 https://vjudge.net/problem/UVALive-3942/origin 字典树维护dp转移 记忆化搜索. const int maxn = 2e6 + 7; const int mod = 20071027; int n, t, m; int dp[maxn], nex 阅读全文
posted @ 2021-07-29 22:02 naymi 阅读(31) 评论(0) 推荐(0)
摘要: 莫队 普通莫队 注意顺序正确!! codes for (int i = 1; i <= m; i++) { int pl = q[i].l, pr = q[i].r; while (l > pl) add(a[--l]); while (r < pr) add(a[++r]); while (l < 阅读全文
posted @ 2021-07-27 19:30 naymi 阅读(29) 评论(0) 推荐(0)
摘要: 牛客多校四 https://ac.nowcoder.com/acm/contest/1125 C:lcs 构造题 不用考虑位置关系...直接放就行了 B:Sample 期望dp F:Just a joke 博弈 画个图很容易发现 对于一个树来说,先手必胜 对于一个带环图来说,记点数为n,边数为m,则 阅读全文
posted @ 2021-07-26 19:31 naymi 阅读(30) 评论(0) 推荐(0)
摘要: 博客园美化步骤 1.百度博客园美化步骤 2.移动鼠标 打开一个教程 3.鼠标滚轮往下 4.鼠标选中代码cccv 5.保存 6.欣赏 阅读全文
posted @ 2021-07-25 20:36 naymi 阅读(29) 评论(0) 推荐(0)
摘要: 牛客多校三 https://ac.nowcoder.com/acm/contest/11254/F dfs 模拟4个[1,13]内的整数加减乘除 能不能在有浮点数出现的情况下 达到m (+ - * /) 在考虑运算先顺序的情况下 + *直接计算 - /需要分谁被减 判断一个数是不是浮点数 只需要他向 阅读全文
posted @ 2021-07-24 19:14 naymi 阅读(42) 评论(0) 推荐(0)
摘要: 消失的一天 线段树 洛谷题单上的线段树挺不错的 就是不会码.. 使用线段树动态维护每个区间的最大值、最长上升子序列 树链剖分 阅读全文
posted @ 2021-07-23 19:15 naymi 阅读(38) 评论(0) 推荐(0)
摘要: 杭电多校二 二进制枚举 https://acm.hdu.edu.cn/showproblem.php?pid=6971 核心问题: 更新数组a[],使 a[i] = max({a[j}),其中,i|k=j 即j能完全包含i 一般情况下 n^2枚举 可以按0的个数建个图比如 111 110 101 0 阅读全文
posted @ 2021-07-22 21:59 naymi 阅读(53) 评论(0) 推荐(0)
摘要: dp 数字三角 https://www.luogu.com.cn/problem/P1216 cin >> n; for (int i = 1; i <= n; i++) for (int j = 1; j <= i; j++) { cin >> a[i & 1][j]; a[i & 1][j] + 阅读全文
posted @ 2021-07-21 23:25 naymi 阅读(47) 评论(0) 推荐(0)
摘要: hud多校一 01字典树 + 前缀异或 http://acm.hdu.edu.cn/contests/contest_showproblem.php?pid=1006&cid=984 公式推导 + bsgs http://acm.hdu.edu.cn/contests/contest_showpro 阅读全文
posted @ 2021-07-20 20:13 naymi 阅读(52) 评论(0) 推荐(0)
摘要: 第二场牛客多校 k: https://ac.nowcoder.com/acm/contest/11253/K //栈模拟 const int maxn = 1e5 + 7; const int mod = 1e9 + 7; int n, m, k, t, a[maxn], b[maxn]; int 阅读全文
posted @ 2021-07-19 20:32 naymi 阅读(49) 评论(0) 推荐(0)
摘要: 补了昨天的E if else 是真的多。。。。 https://codeforces.com/contest/1530/problem/E #define mid ((tr[k].l + tr[k].r) >> 1) #define ls k << 1 #define rs k << 1 | 1 c 阅读全文
posted @ 2021-07-18 11:33 naymi 阅读(56) 评论(0) 推荐(0)
摘要: 第一场牛客多校真的稀碎。。 link A.SG暴力打表 B.简单初中计算几何 E.签到 F.规律题 显然多于100就没可能有不符合条件的了,但是也可以数位dp.这个数位dp挺复杂的(我太菜了。。。)。 \(dp[pos][sum][sta][flag][limit][lead]\) pos 为 位置 阅读全文
posted @ 2021-07-17 20:12 naymi 阅读(30) 评论(0) 推荐(0)
摘要: 效率挺低的。。 写了个概率dfs..esp应该调小点的 1e-13 有个分块树处理群运算(满足结合律)的板子 oiWiki. //下标从0开始 SqrtTreeItem op(const SqrtTreeItem &a, const SqrtTreeItem &b); inline int log2 阅读全文
posted @ 2021-07-16 22:44 naymi 阅读(45) 评论(0) 推荐(0)
摘要: 题目比较难读,因为n很小因此可以枚举哪一个点为根节点,计算每对逆序对的贡献(就是概率) 对于一个逆序对产生的贡献,可以看成较大节点先选中的概率,可以用dp预处理求出(u,v)到父节点p的概率 倍增求lca. https://codeforces.com/contest/1541/problem/D 阅读全文
posted @ 2021-07-15 20:28 naymi 阅读(62) 评论(0) 推荐(0)
摘要: Educational Codeforces Round 111 (Rated for Div. 2) 7.25 upd. C. Manhattan Subarrays 比赛的时候想出来了 过了一周全忘了... 因为是统计整个数组的good arrays 序号就是点的横坐标 又因为 不组成bad t 阅读全文
posted @ 2021-07-14 20:32 naymi 阅读(47) 评论(0) 推荐(0)