上一页 1 ··· 54 55 56 57 58 59 60 61 62 ··· 67 下一页
摘要: $dijkstra$最短路径计数,注意判输入时的重复数据(=_=) const int N=2010; struct Node { int a,b,c; bool operator<(const Node &W) const { if(a == W.a) { if(b == W.b) return 阅读全文
posted @ 2020-11-24 10:38 Dazzling! 阅读(96) 评论(0) 推荐(0) 编辑
摘要: 比较裸的拆点最短路吧 注意特判起点终点相等的情况,起点终点相等不需要换乘任何线路,答案为0 const int N=1010,M=510; struct Node { int u,line,dis; bool operator>(const Node &W) const { return dis>W 阅读全文
posted @ 2020-10-23 10:32 Dazzling! 阅读(116) 评论(0) 推荐(0) 编辑
摘要: $MST$板子题 const int N=5e5+10; struct Node { int a,b,c; bool operator<(const Node &W) const { return c<W.c; } }e[N]; int p[N]; int n,m; int find(int x) 阅读全文
posted @ 2020-10-10 23:07 Dazzling! 阅读(85) 评论(0) 推荐(0) 编辑
摘要: dijkstra $dijkstra$求最短路中我们每次选取的是离原点的最短边来松弛剩下的节点 在这里我们要找到到达终点的的一条路使其路径上的最小边尽量大,才能使其载重量较大。 也就是说每次选择一个从源点到某个载重量最大的点,来松弛其他点。 $dist$将记录到达每个点的路径上的最小载重,选择最大的 阅读全文
posted @ 2020-10-10 17:57 Dazzling! 阅读(88) 评论(0) 推荐(0) 编辑
摘要: 同追债之旅 分层图最短路 每次的决策:用/不用免费票 const int N=10010; vector<PII> g[N]; struct Node { int dis,u,cnt; bool operator>(const Node &W) const { return dis>W.dis; } 阅读全文
posted @ 2020-10-10 11:56 Dazzling! 阅读(82) 评论(0) 推荐(0) 编辑
摘要: 最短路变形题,加一维状态就好啦 $dist[i][j]$表示到达第$i$号点,到达时间为第$j$天的最短距离 判重数组要和$dist$数组一致 直接跑$dijkstra$即可 const int N=1010; vector<PII> g[N]; struct Node { int dis,u,da 阅读全文
posted @ 2020-10-10 11:36 Dazzling! 阅读(96) 评论(0) 推荐(0) 编辑
摘要: \(update\) 如果按照正确理解题意的情况下, 好多题解的代码都错的啊,但毕竟十几年前的题了,数据水了 二分 一眼二分 最后输出答案前一定要$check$一遍最优解,才能得到正确的方案 const int N=10010,M=20010; struct Edge { int a,b,c; }e 阅读全文
posted @ 2020-10-04 22:04 Dazzling! 阅读(94) 评论(0) 推荐(0) 编辑
摘要: 太菜了。。。这么简单的模型都看不出来。。。 模型:图的直径 注意:原题为无向图 暴力思路:从$1000$个点中选取$3$个点的排列,然后求路径和。 上述思路过于暴力,我们知道$dijkstra$算法求得的$dist$数组是源点$s$到其余点的最短距离 我们只需将源点看成中转点,然后求出当前点到其余点 阅读全文
posted @ 2020-10-04 20:22 Dazzling! 阅读(113) 评论(0) 推荐(0) 编辑
摘要: $MST$裸题 const int N=110; int g[N][N]; int dist[N]; bool vis[N]; int money; int n,m; int prim() { memset(dist,0x3f,sizeof dist); memset(vis,0,sizeof vi 阅读全文
posted @ 2020-10-04 17:22 Dazzling! 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 因为每组至多选择一个物品,可以将每组看做一个整体,这样就类似于01背包问题。 用$f(i,j)$表示前$i$组物品放入一个容量不超过$j$的背包可以获得的最大价值。 对于第$i$组物品: 不放入第$i$组物品,\(f(i,j)\)=\(f(i-1,j)\) 放入第$i$组的第$k$个物品,\(f(i 阅读全文
posted @ 2020-10-02 22:32 Dazzling! 阅读(209) 评论(0) 推荐(0) 编辑
上一页 1 ··· 54 55 56 57 58 59 60 61 62 ··· 67 下一页