十七

acwing2.01背包问题

朴素版(二维)状态f[i][j]定义:前 ii 个物品,背包容量 jj 下的最优解(最大价值):当前的状态依赖于之前的状态,可以理解为从初始状态f[0][0] = 0开始决策,有 NN 件物品,则需要 NN 次决 策,每一次对第 ii 件物品的决策,状态f[i][j]不断由之前的状态更新而来。2.

十七 Published on 2022-02-16

acwing859. Kruskal算法求最小生成树

#include<iostream>#include<algorithm>using namespace std;const int N=1e5+10,M=2e5+10,INF=0x3f3f3f3f;int p[N],n,m;struct Edge{ int a,b,w

十七 Published on 2022-02-16

acwing852. spfa判断负环

#include<iostream>#include<cstring>#include<queue>using namespace std;const int N=1e5+10;int ne[N],e[N],h[N],idx,w[N];int n,m,dist[N

十七 Published on 2022-02-15

acwing851. spfa求最短路

#include<iostream>#include<cstring>#include<queue>using namespace std;const int N=1e5+10;int ne[N],e[N],h[N],idx,w[N];int n,m,dist[N

十七 Published on 2022-02-15

acwing853. 有边数限制的最短路

#include<iostream>#include<cstring>using namespace std;const int N=510,M=10010;int n,m,k;int dist[N],last[N];struct Edge{ int a,b,c;

十七 Published on 2022-01-24
十七 Published on 2022-01-22

acwing844. 走迷宫

#include<iostream>#include<cstring>#include<queue>using namespace std;typedef pair<int,int> PII;const int N=105;int n,m,g[N][N

十七 Published on 2022-01-17

acwing840. 模拟散列表

拉链法#include<iostream>#include<cstring>using namespace std;const int N=100003;int e[N],ne[N],h[N],idx;void insert(int x){ int k=(x%N+N)%

十七 Published on 2022-01-15

acwing838. 堆排序

#include<iostream>using namespace std;const int N=1e5+10;int n,m,a[N],cnt;void down(int x){ int u=x; if(2*x<=cnt&&a[2*x]<a[u

十七 Published on 2022-01-14

acwing240. 食物链

题目描述动物王国中有三类动物 A,B,C,这三类动物的食物链构成了有趣的环形。A 吃 B,B 吃 C,C 吃 A。现有 N 个动物,以 1∼N 编号。每个动物都是 A,B,C 中的一种,但是我们并不知道它到底是哪一种。有人用两种说法对这 N 个动物所构成的食物链关系进行描述:第一种说法是 1 X Y

十七 Published on 2022-01-14
Previous Next