LH_Coffee
LH_Coffee
全部文章
分类
题解(1)
归档
标签
去牛客网
登录
/
注册
LH_Coffee的博客
全部文章
(共23篇)
题解 | #[USACO 2010 Nov S]Chocolate Milk#
using namespace std; const int N=100005; int h[N],to[N],ne[N],cnt=1;//链式前向星 int inde[N],outde[N],q[N],ans[N];//入度,出度,队列模拟,记录到每个点时前面点的贡献 int head=0,tai...
C++
2026-05-06
0
26
题解 | 村村通工程
#include<bits/stdc++.h> using namespace std; const int N=1e5+5; int f[N]; int find(int x){ if(f[x]!=x)f[x]=find(f[x]); return f[x]; } s...
2026-04-25
0
25
题解 | 修复公路
#include<bits/stdc++.h> using namespace std; const int N=1e3+5; const int M=1e5+5; int f[N]; struct node{ int x,y,w; }a[M]; int find(int x...
2026-04-25
0
27
题解 | kmp算法
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 计算模板串S在文本串T中出现了多少次 * @param S string字符串 模板串 * @pa...
2026-04-22
1
48
题解 | 单调栈
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param nums int整型vector * @return int整型vector...
2026-04-19
1
36
题解 | 迷宫问题
#include<bits/stdc++.h> using namespace std; typedef pair<int,int>PII; const int N=105; int mp[N][N]; PII path[N][N]; queue<PII>q; i...
2026-03-09
1
58
题解 | 小红的双排列删除得分
#include <bits/stdc++.h> using namespace std; struct nod { int fir; // 数字第一次出现的位置 int sec; // 数字第二次出现的位置 // 带默认参数的构造函数 nod(in...
2026-02-28
2
80
题解 | 跳台阶
动态规划三部曲(递推---->递推+记忆化搜索----->自底到顶的动态规划---->状态压缩)1.递推(自顶到底)本题可类比斐波那契,每次跳台阶与前一个和前两个有关所以到n目标位置有如下关系:f(n)=f(n-1)+f(n-2) f是计算方案数的函数,这是递推的核心,再加上边界讨...
2026-02-04
4
103
题解 | 【模板】快速幂
#include <iostream> using namespace std; using ll=long long; ll f(ll a,ll b,ll p){ ll ans=1; a%=p; while(b){ if(b&1){ ...
2026-02-02
1
94
题解 | 斐波那契数列
#include <iostream> using namespace std; using ll=long long; ll fbnq(int n){ if(n<=2)return 1; return fbnq(n-1)+fbnq(n-2); } int main...
2026-02-02
1
99
首页
上一页
1
2
3
下一页
末页