朴素版(二维)状态f[i][j]定义:前 ii 个物品,背包容量 jj 下的最优解(最大价值):当前的状态依赖于之前的状态,可以理解为从初始状态f[0][0] = 0开始决策,有 NN 件物品,则需要 NN 次决 策,每一次对第 ii 件物品的决策,状态f[i][j]不断由之前的状态更新而来。2.
#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
#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
#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
#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;
#include<iostream>#include<cstring>#include<queue>using namespace std;typedef pair<int,int> PII;const int N=105;int n,m,g[N][N
拉链法#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)%
#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
题目描述动物王国中有三类动物 A,B,C,这三类动物的食物链构成了有趣的环形。A 吃 B,B 吃 C,C 吃 A。现有 N 个动物,以 1∼N 编号。每个动物都是 A,B,C 中的一种,但是我们并不知道它到底是哪一种。有人用两种说法对这 N 个动物所构成的食物链关系进行描述:第一种说法是 1 X Y