会员
周边
新闻
博问
闪存
众包
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
matt-11
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
5
6
7
8
9
10
11
12
13
···
15
下一页
2022年1月9日
leetcode 5978. 统计追加字母可以获得的单词数
摘要: 1 class Solution { 2 public: 3 int wordCount(vector<string>& startWords, vector<string>& targetWords) { 4 int n=startWords.size(),ans=0; 5 unordered_s
阅读全文
posted @ 2022-01-09 13:54 matt-11
阅读(38)
评论(0)
推荐(0)
2022年1月7日
洛谷 P3373 【模板】线段树 2 区间加、区间乘
摘要: 1 #include<bits/stdc++.h> 2 #define ls (x<<1) 3 #define rs (x<<1|1) 4 #define rep(i,a,b) for(int i=a;i<=b;i++) 5 #define pb(a) push_back(a) 6 using na
阅读全文
posted @ 2022-01-07 21:44 matt-11
阅读(43)
评论(0)
推荐(0)
洛谷 P3372 【模板】线段树 1
摘要: 这题是线段树的区间加、区间修改和懒标记,注意开long long 1 #include<bits/stdc++.h> 2 #define ls (x<<1) 3 #define rs (x<<1|1) 4 #define rep(i,a,b) for(int i=a;i<=b;i++) 5 #def
阅读全文
posted @ 2022-01-07 17:04 matt-11
阅读(55)
评论(0)
推荐(0)
leetcode 剑指 Offer 43. 1~n 整数中 1 出现的次数
摘要: 1 int dp[11][11]; 2 int a[11]; 3 4 class Solution { 5 public: 6 long long dfs(int eq,int dep,int sum) 7 { 8 if(!dep)return sum; 9 if(~dp[dep][sum]&&!e
阅读全文
posted @ 2022-01-07 13:29 matt-11
阅读(31)
评论(0)
推荐(0)
2022年1月6日
leetcode 剑指 Offer 60. n个骰子的点数
摘要: 1 class Solution { 2 public: 3 vector<double> dicesProbability(int n) { 4 int dp[n+1][70]; 5 memset(dp,0,sizeof(dp)); 6 for(int i=1;i<=6;i++)dp[1][i]=
阅读全文
posted @ 2022-01-06 21:59 matt-11
阅读(33)
评论(0)
推荐(0)
leettcode 剑指 Offer 51. 数组中的逆序对
摘要: 1 class Solution { 2 public: 3 int reversePairs(vector<int>& nums) { 4 int n=nums.size(); 5 int a[n+1]; 6 function<int(int,int)>merge=[&](int l,int r)
阅读全文
posted @ 2022-01-06 21:08 matt-11
阅读(44)
评论(0)
推荐(0)
2022年1月4日
leetcode 913. 猫和老鼠
摘要: 博弈论dp,记忆化搜索,从最开始的状态去搜; dp[mouse][cat][turn]表示当前mouse ,cat,turn三种状态下先手能获得的最优解,其中优先级赢>和>输; 1 class Solution { 2 public: 3 4 int catMouseGame(vector<vect
阅读全文
posted @ 2022-01-04 20:40 matt-11
阅读(60)
评论(0)
推荐(0)
prim算法求最小生成树
摘要: 每次利用已经加入生成树的点集寻找未加入的点集的最小边,然后添加该点,并把minw[u]设置为最小生成树到u的最小距离; 证明算法正确性; 如果存在x1 x2均能联通到达生成树,其中若minw[x2]>minw[x1] 此时选x2加入生成树一定没有选X1优,正确性可以保证; 1 #include<bi
阅读全文
posted @ 2022-01-04 11:31 matt-11
阅读(75)
评论(0)
推荐(0)
2022年1月3日
SPFA算法
摘要: 就是一种优化思想,基于搜索的思想,dijsktra堆优化也差不多是这样,只不过堆优化加了启发式选dis[u]较小的先更新,类似普通搜索与A*的区别;
阅读全文
posted @ 2022-01-03 17:24 matt-11
阅读(30)
评论(0)
推荐(0)
Bellmand-Ford算法思想
摘要: 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int N=1e5+5; 4 int dis[N],n,m; 5 struct edge 6 { 7 int u,v,w; 8 }e[N]; 9 //对每条边进行松弛,每次松弛至少能更新
阅读全文
posted @ 2022-01-03 17:13 matt-11
阅读(36)
评论(0)
推荐(0)
上一页
1
···
5
6
7
8
9
10
11
12
13
···
15
下一页
公告