chenlan114
chenlan114
全部文章
分类
题解(1)
归档
标签
去牛客网
登录
/
注册
chenlan114的博客
全部文章
(共83篇)
题解 | 1=N
#include<bits/stdc++.h> using namespace std; using ll = long long; const ll N = 3e5; vector<ll> primes; // 存储筛出的所有质数 vector<b...
2026-04-03
0
59
题解 | 冥古之潮
#include<bits/stdc++.h> using namespace std; using ll = long long; const ll N = 1e6 + 5; const ll MOD = 1e9 + 7; vector<vector<ll>&g...
2026-04-01
0
53
题解 | 最大最小路
#include<bits/stdc++.h> using namespace std; using ll=long long; struct UF{ UF* root; ll rank=0; ll cnt=1; }; UF* Root(UF* a){ ...
2026-03-31
0
50
题解 | Forsaken喜欢数论
#include <iostream> #include <vector> using namespace std; using ll = long long; const ll N = 3e7; // 质数筛选最大范围 vector<ll> primes; ...
2026-03-28
0
46
题解 | 太阳之华
#include<bits/stdc++.h> using namespace std; using ll=long long; const ll N=2e3+5; vector<vector<char>>g; vector<vector<bool&g...
2026-03-24
0
60
题解 | 三视图
#include<bits/stdc++.h> using namespace std; using ll=long long; const ll N=1e3+5; bool vis1[N][N]; bool vis2[N][N]; bool vis3[N][N]; int main(...
2026-03-16
0
61
题解 | 显生之宙
#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
63
题解 | 食物链计数
采用反向记忆化 DFS的思路,统计 DAG 上符合题目定义的食物链数量,核心逻辑如下:明确题目定义与代码的对应关系题目要求的食物链是:生产者(出度为0,起点) → 沿有向边 → 顶级消费者(入度为0,终点)。代码采用反向统计的思路,从终点(入度为 0 的顶级消费者)出发,反向遍历到起点(出度为 0 ...
2026-03-12
0
74
题解 | 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
67
题解 | 小苯的蓄水池(hard)
核心算法:结合「并查集(路径压缩 + 按秩合并)」和「跳跃指针(nxt 数组)」,解决区间合并的超时问题;核心逻辑:并查集维护连通块的数值和、节点数,支持快速查询平均值;跳跃指针nxt[i]记录连通块右边界的下一个位置,合并时直接跳过整个连通块,避免逐点遍历;优化目标:将区间合并的时间复杂度从 O ...
2026-03-09
0
72
首页
上一页
1
2
3
4
5
6
7
8
9
下一页
末页