摘要: 初始化$g[i][j]$为INF表示没被炸毁 导弹连同周围四个区域一同炸毁 多次炸毁的区域炸毁时间取第一次炸毁的时间 const int N=50010; int g[310][310]; int dist[310][310]; int n; bool check(int x,int y) { re 阅读全文
posted @ 2020-09-15 18:27 Dazzling! 阅读(145) 评论(0) 推荐(0) 编辑
摘要: \(bfs\) const int N=210; int k[N]; int dist[N]; int n,a,b; inline bool check(int x) { return x>=1 && x<=n; } int bfs() { memset(dist,-1,sizeof dist); 阅读全文
posted @ 2020-09-14 17:12 Dazzling! 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 桶排序 const int N=1010; int cnt[N]; int n,m; int main() { cin>>n>>m; for(int i=0;i<m;i++) { int x; scanf("%d",&x); cnt[x]++; } for(int i=0;i<1000;i++) f 阅读全文
posted @ 2020-09-08 21:27 Dazzling! 阅读(228) 评论(0) 推荐(0) 编辑
摘要: 一眼二分: 二分出最近的两个部落之间的最大距离,判断当前mid距离下能否划分成k个连通块 const int N=1010; PII a[N]; int p[N]; double dist[N][N]; int n,k; double dis(PII a,PII b) { return sqrt(( 阅读全文
posted @ 2020-09-08 11:57 Dazzling! 阅读(131) 评论(0) 推荐(0) 编辑
摘要: $kruskal$每增加一条边都会使连通块数减一 const int N=10010; struct Node { int a,b,c; bool operator<(const Node &W) const { return c<W.c; } }e[N]; int p[N]; int n,m,k; 阅读全文
posted @ 2020-09-08 09:04 Dazzling! 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 图被划分成两块连通块,现用一条边将两块连通块连接起来,使得图的直径(最远的两个点的最短距离)最小 既然要求最短路径,观察数据范围,采用Floyd算法求得任意两点间最短路径 然后枚举所有不连通的两点,判断以当前两点间的距离为边将连通块连通得到的图的直径是否最小(在此之前要预处理出每个点在连通块内所能抵 阅读全文
posted @ 2020-09-07 22:20 Dazzling! 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 最大的一次收费最小,不由联想到二分 二分最大的一次收费mid,则要求从1走到n的路径上经过的点所收取的费用均不能超过mid 为了判断当前取mid能否走到终点,采用贪心的思想,应该走从1到n的最短路径(路径上的权值表示伤害,初始血量为b),即伤害最小 判断在伤害最小的路径上能否走到终点 const i 阅读全文
posted @ 2020-09-07 18:34 Dazzling! 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 最小瓶颈路单次询问模板题,s和t一旦连通输出对应的最大边即可 const int N=2e4+10; struct Node { int a,b,c; bool operator<(const Node &W) const { return c<W.c; } }e[N]; int p[N]; int 阅读全文
posted @ 2020-09-07 14:58 Dazzling! 阅读(132) 评论(0) 推荐(0) 编辑
摘要: $kruskal$同样可用于求最大生成树,本题只需求出最大生成树的前$k$条边即可 const int N=1e5+10; struct Node { int a,b,c; bool operator<(const Node &W) const { return c>W.c; } }e[N]; in 阅读全文
posted @ 2020-09-07 14:05 Dazzling! 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 如果$g[i][j] != 0$ ,则购买$i$后只需再花费$g[i][j]$购买$j$即可,于是从$i$向$j$连一条边权为$g[i][j]$的边 如果$g[i][j] == 0$,则购买$i$后只能花费$w$购买$j$,于是从$i$向$j$连一条边权为$w$的边 对所有的$i,j∈[1,n]$进 阅读全文
posted @ 2020-09-06 16:44 Dazzling! 阅读(138) 评论(0) 推荐(0) 编辑