文章分类 -  算法蒟蒻

上一页 1 2 3 4 5 6 ··· 14 下一页
摘要:【翻硬币问题】 Entangled Coins https://ac.nowcoder.com/acm/contest/108302/A 题目大意 思路 代码 const int N=3e5+10; i64 n,k,s,t; void solve(){ cin>>n>>k>>s>>t; if(n== 阅读全文
posted @ 2025-08-20 18:35 White_ink 阅读(4) 评论(0) 推荐(0)
摘要:【LCA】最近公共祖先 LCA(x,y) 模版代码 模版题 https://www.luogu.com.cn/problem/P3379 树上倍增 基础封装:针对无权图 把空间开到全局 struct Tree { int n; vector<vector<int>> ver, val; vector 阅读全文
posted @ 2025-08-15 15:04 White_ink 阅读(6) 评论(0) 推荐(0)
摘要:【C++魅力时刻】 记录一些因为语法问题不报RECE导致的WA 边界问题 本题n,m,a[i][j]范围 <=500 注意multiset特判if(son>min(n,m)) continue;否则count计数会比较奇怪 const int N=500; int n,m; multiset<int 阅读全文
posted @ 2025-08-15 11:24 White_ink 阅读(6) 评论(0) 推荐(0)
摘要:【链+环结构】 有时题目造样例打表迭代完 会得到链+环的结构 链单独算 环统一算 最后环断链的单独算 幂中幂plus https://ac.nowcoder.com/acm/contest/113313/F 注意这题代码的简洁程度 思路 打表可以发现规律是一个链+环 直接模拟即可 注意快速幂不要爆l 阅读全文
posted @ 2025-08-12 21:58 White_ink 阅读(7) 评论(0) 推荐(0)
摘要:【高维DP】 dp[][][][][]... 数据范围一般都很小(十位数),每层转移比较麻烦但是不难想 Lost Woods https://ac.nowcoder.com/acm/contest/108304/D 题目大意 阅读全文
posted @ 2025-08-06 14:14 White_ink 阅读(5) 评论(0) 推荐(0)
摘要:【括号匹配】 题目整理 Ghost in the Parentheses https://ac.nowcoder.com/acm/contest/108301/G 题目大意 思路 【本题关键】 (1)将'('看成+1 ')'看成-1:做前缀和找规律 ->可发现合法的括号序列所有的前缀和一定是非负的 阅读全文
posted @ 2025-07-25 00:53 White_ink 阅读(22) 评论(0) 推荐(0)
摘要:【限制次数】 结论题?x 暴力限制次数可过的题目 常见模型 Jetton https://ac.nowcoder.com/acm/contest/108300/J 题目大意 阅读全文
posted @ 2025-07-24 11:57 White_ink 阅读(4) 评论(0) 推荐(0)
摘要:【容斥原理】 计算多个集合的并集大小 公式 + - + - + ...以此类推 若有A,B,C,D,E五个集合 则有并集个数 A+B+C+D+E -(AB+AC+AD+AE+BC+BD+BE+CD+CE+DE) +(ABC+ABD+ABE+BCD+BCE+CDE) -(ABCD+ABCE+BCDE) 阅读全文
posted @ 2025-07-23 00:31 White_ink 阅读(8) 评论(0) 推荐(0)
摘要:【计算几何板子】 初始板子 遇到计算几何的题目就用这个模版来写 #include<bits/stdc++.h> using namespace std; #define endl '\n' #define whiteink signed main #define fi first #define s 阅读全文
posted @ 2025-07-19 22:06 White_ink 阅读(15) 评论(0) 推荐(0)
摘要:【树上模拟】 1-1-1, Free Tree! https://codeforces.com/contest/2126/problem/F 树很关键的一个优化点:父亲有且只有一个 ->将遍历出边O(n)优化到:遍历父亲O(1)/儿子(如果可以一起维护) 题目大意 思路 难点在于每次修改颜色之后需要 阅读全文
posted @ 2025-07-18 11:29 White_ink 阅读(42) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 ··· 14 下一页