- 博客(6)
- 收藏
- 关注
原创 【算法题】洛谷 P3958 [NOIP2017 提高组] 奶酪
【题目来源】[NOIP2017 提高组] 奶酪 - 洛谷【分析】看数据规模,T<=20,n<=1e3,则每次询问可以承受O(n^2)。采用广度优先搜索,把从底部能进入的洞加入队列,并标记vis=1(可到达),然后开始搜索,每个与队列中连通的洞可以加入队列(条件:洞心距离<=2*r),并标记其vis=1。最后判断是否存在这样的洞:(1)能到达顶部(2)vis=1。特别注意爆int,int数据做运算,每一部分都要强制转换成long long型:ll dist(PO
2021-09-14 21:29:25 245
原创 【算法题】洛谷 P3367 【模板】并查集
【题目来源】【模板】并查集 - 洛谷【分析】#并查集【代码】#include<iostream>#include<cstdio>#include<algorithm>#define ll long longusing namespace std;const int N=1e4+5;int n,m;int f[N];int findf(int x){ return x==f[x]?x:f[x]=findf(f[x]);}
2021-09-14 20:26:49 87
原创 【算法题】洛谷 P3374 【模板】树状数组 1
【题目来源】【模板】树状数组 1 - 洛谷【分析】#树状数组【代码】#include<iostream>#include<cstdio>#include<algorithm>#define ll long longusing namespace std;const int maxn=5e5+5;int n,m;ll sum[maxn];inline int lowbit(int x){ return x&-x;
2021-09-14 20:12:16 68
原创 【算法题】洛谷 P3366 【模板】最小生成树
【题目来源】【模板】最小生成树 - 洛谷【分析】#最小生成树#并查集#前向星存图#克鲁斯卡尔【代码】#include<iostream>#include<cstdio>#include<algorithm> //sort函数 using namespace std;const int N=5000+5;const int M=2e5+5;struct edge{ int u,v,w;}e[M];int n,m
2021-09-14 13:26:44 65
原创 【算法题】洛谷 P4779 【模板】单源最短路径(标准版)
【题目来源】【模板】单源最短路径(标准版) - 洛谷【分析】#迪杰斯特拉(堆优化)【代码】#include<iostream>#include<cstdio>#include<cstring> #include<queue>using namespace std;const int N=1e5+5;const int M=2e5+5;const int INF=1e9+5;struct edge{ int fr
2021-09-13 23:26:22 99
原创 【算法题】洛谷 P1451 求细胞数量
【题目来源】求细胞数量 - 洛谷【题目】【算法】深度优先搜索(DFS)【代码】#include<cstdio>#include<string>#include<iostream>using namespace std;const int dx[]={0,0,1,-1};const int dy[]={1,-1,0,0};const int N=100+1;const int M=100+1;int n,...
2021-09-12 22:24:01 158
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人