会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
dfydn
博客园
首页
新随笔
联系
订阅
管理
上一页
1
2
3
4
5
6
7
8
9
···
29
下一页
2021年5月30日
How far away ? HDU
摘要: LCA应用求最短路 #include<cstdio> #include<iostream> #include<cstring> using namespace std; const int N=40005; int T,n,m,ans,tot; struct node{ int to,next,w;
阅读全文
posted @ 2021-05-30 17:54 dfydn
阅读(45)
评论(0)
推荐(0)
2021年5月23日
最短路计数
摘要: 将计数融入最短路中,即 if(dis[v]==dis[u]+edge[i].w){ ans[v]+=ans[u]; ans[v]%=mod; } #include<cstdio> #include<iostream> #include<cstring> #include<queue> using n
阅读全文
posted @ 2021-05-23 16:55 dfydn
阅读(57)
评论(0)
推荐(0)
[USACO09FEB]Revamping Trails G
摘要: 分层图最短路,注意数组范围 #include<cstdio> #include<iostream> #include<cstring> #include<queue> using namespace std; const int N=2000005; int n,m,tot,k; bool vis[
阅读全文
posted @ 2021-05-23 16:37 dfydn
阅读(39)
评论(0)
推荐(0)
部落划分
摘要: 每合并一次,部落数减一,最终合并到合法的数量。 若i时得到nk时,不能确定w[i+1]即为答案,因为可能u[i+1].fv[i+1].f,所以还需要再往下枚举判断。 #include<cstdio> #include<iostream> #include<cstring> #include<cmat
阅读全文
posted @ 2021-05-23 16:04 dfydn
阅读(119)
评论(0)
推荐(0)
[USACO14MAR]Watering the Fields S
摘要: 欧几里得距离不需要开根号,题目描述联通的最小代价指的是和。 细节: 1.因为克鲁斯卡尔算法枚举的是边,所以不需要在意是无向图,仅存一遍即可,即32、33行,j直接从i+1开始枚举。 2.最后判断时,如果tot==n-1,让其break,再外面再进行其他操作会更快一些。 #include<cstdio
阅读全文
posted @ 2021-05-23 15:12 dfydn
阅读(57)
评论(0)
推荐(0)
2021年5月19日
无线通讯网
摘要: #include<cstdio> #include<iostream> #include<cstring> #include<cmath> #include<algorithm> using namespace std; const int N=505; int s,p,tot,cnt; struc
阅读全文
posted @ 2021-05-19 11:28 dfydn
阅读(60)
评论(0)
推荐(0)
2021年5月16日
飞行路线
摘要: 分层图最短路 范围要开的足够大 注意: add(u+j * n,v+j * n,w); add(v+j * n,u+j * n,w); add(u+(j-1) * n,v+j * n,0); add(v+(j-1) * n,u+j * n,0); 最后终点之间连上边权为0的边 #include<cs
阅读全文
posted @ 2021-05-16 17:07 dfydn
阅读(147)
评论(0)
推荐(0)
2020年11月5日
洛谷 P2758 编辑距离(DP)
摘要: 题目链接:https://www.luogu.com.cn/problem/P2758 设f[i][j]表示把A中[1,i]变成B中[1,j]的最小操作数。 如果A[i]==B[j],那么直接转移。 否则有三种情况: f[i][j]=f[i-1][j-1],把A[i]换成B[j] f[i][j]=f
阅读全文
posted @ 2020-11-05 21:46 dfydn
阅读(71)
评论(0)
推荐(0)
洛谷 P1970 花匠(DP)
摘要: 题目链接:https://www.luogu.com.cn/problem/P1970 AC代码: 1 #include<cstdio> 2 #include<iostream> 3 using namespace std; 4 const int N=100010; 5 int a[N],f[N]
阅读全文
posted @ 2020-11-05 20:38 dfydn
阅读(109)
评论(0)
推荐(0)
洛谷 P6154 游走(toposort+期望)
摘要: 题目链接:https://www.luogu.com.cn/problem/P6154 拓扑排序+快速幂求逆元 AC代码: 1 #include<cstdio> 2 #include<iostream> 3 #include<queue> 4 #include<cstring> 5 using na
阅读全文
posted @ 2020-11-05 20:21 dfydn
阅读(105)
评论(0)
推荐(0)
上一页
1
2
3
4
5
6
7
8
9
···
29
下一页
公告