自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(7)
  • 收藏
  • 关注

原创 最短路

Floydfor (k = 1; k <= n; k++) { for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]); } }}Dijkstravoid dijkstra(int n){ int visit[1001]={0}; int min,i,j,k; visi

2021-01-31 08:20:13 66

原创 dp

动态规划算法有两个基本要点一是拆分问题;二是定义问题状态和状态之间的关系。通过递归或滚动数组的方式来求解

2021-01-28 08:09:00 80

原创 线段树

#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int N=100010;int a[N],b[N];struct segmentTree { int l,r,sum;} node[N << 2];void pushUp(int i) { node[i].sum = node

2021-01-26 08:11:00 71

原创 bfs和dfs

#define pii pair<int,int>int dx[M]={0,0,1,-1};int dy[M]={1,-1,0,0};int sx,sy;void bfs(){ queue<pii>q; q.push(make_pair(sx,sy)); dis[sx][sy]=0; while(!q.empty()){ int x=q.front().first,y=q.front().second; q.pop(); for(int i=0;i<

2021-01-24 08:13:17 101

原创 二分查找

#include<stdio.h>#include<iostream>#include <algorithm>using namespace std;const int maxN=1e8;int n,m;int a[maxN];bool p(int x){ int f=a[0],sum=1; for(int i=1;i<n;i++){ if(a[i]-f>=x){ f=a[i]; sum++; } if(sum>

2021-01-23 08:31:01 142

原创 并查集的实现

并查集,即把有关系的一部分放到一个集合中。主要函数有两个:int find(int i){ if(f[i]==i) return i; else{ f[i] = find(f[i]); return f[i]; }}这段代码主要实现找到 i 的祖宗以及实现路径压缩,void merge(int i,int j){ int t1,t2; t1 = getf(i); t2 = getf(j); if

2021-01-22 07:36:54 75

原创 Let the Balloon Rise HDU-1004

Let the Balloon RiseContest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges’ favorite time is guessing the most popular problem. When the contest is over, they will count the balloons of each color and f

2021-01-20 22:41:54 81

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除