chenlan114
chenlan114
全部文章
分类
题解(1)
归档
标签
去牛客网
登录
/
注册
chenlan114的博客
全部文章
(共67篇)
题解 | 显生之宙
#include<bits/stdc++.h> using namespace std; using ll=long long; int main(){ ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); ll T; ...
2026-03-13
0
8
题解 | 食物链计数
采用反向记忆化 DFS的思路,统计 DAG 上符合题目定义的食物链数量,核心逻辑如下:明确题目定义与代码的对应关系题目要求的食物链是:生产者(出度为0,起点) → 沿有向边 → 顶级消费者(入度为0,终点)。代码采用反向统计的思路,从终点(入度为 0 的顶级消费者)出发,反向遍历到起点(出度为 0 ...
2026-03-12
0
6
题解 | Tokitsukaze and Colorful Chessboard
#include<bits/stdc++.h> using namespace std; using ll=long long; const ll N=1e5; ll pre[N]; int main(){ ios::sync_with_stdio(0),cin.tie(0),...
2026-03-11
0
10
题解 | 小苯的蓄水池(hard)
核心算法:结合「并查集(路径压缩 + 按秩合并)」和「跳跃指针(nxt 数组)」,解决区间合并的超时问题;核心逻辑:并查集维护连通块的数值和、节点数,支持快速查询平均值;跳跃指针nxt[i]记录连通块右边界的下一个位置,合并时直接跳过整个连通块,避免逐点遍历;优化目标:将区间合并的时间复杂度从 O ...
2026-03-09
0
15
题解 | 连分数
#include<bits/stdc++.h> using namespace std; using ll=long long; void solve(ll P,ll Q){ cout<<P<<'/'<<Q<<" = &...
2026-03-08
0
10
题解 | Rinne Loves Edges
#include<bits/stdc++.h> using namespace std; using ll=long long; const ll N=1e5+5,inf=9e18; struct E{ ll u,w; }; ll n,m,s; vector<vector&...
2026-03-07
0
12
题解 | 不点两面(hard version)
#include<bits/stdc++.h> using namespace std; using ll=long long; int main(){ ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); ll m,q; ...
2026-03-06
0
17
题解 | 多米诺骨牌
阶段 1:输入处理与数据预处理目标:读取输入数据,并将物体按位置排序,保证从左到右处理区间。操作:读取多组测试用例(T 组),每组先读物体数量 n、选取组数 m;按题目要求的输入顺序:先批量读取所有物体的高度 h,再批量读取所有物体的位置 x;将每个物体的 (x, h) 封装为结构体,按位置 x 升...
2026-03-04
1
20
题解 | 小苯的最大和
#include <bits/stdc++.h> using namespace std; using ll=long long; const ll N=2e5+5; vector<ll>a; vector<ll>f; int main() { ios...
2026-03-03
0
19
题解 | 隐匿社交网络
#include<bits/stdc++.h> using namespace std; using ll=long long; const ll N=1e5+5; ll ans; // 存储每组测试用例的最大连通分量大小 // 并查集(Union-Find)节点结构体:用于管理二...
2026-02-25
0
39
首页
上一页
1
2
3
4
5
6
7
下一页
末页