#include using namespace std; //算法提高 种树 //这是01背包问题的变形 //环的处理方法 1.找到最小值的位置,预处理数组,比如 56 21 64 32 45 -> 21 64 32 45 56 21 //这样就相邻了而且21 21肯定不会同时选到 //2.还可以... ...
分类:
其他好文 时间:
2020-06-06 21:43:45
阅读次数:
71
#include using namespace std; // 走两次是不行的,因为这就是贪心了。。 // 需要多线程dp,就是想象有2个人同时走,他们可以走到一起,但是必须只加一次; // 转移方程: // (1)a,b都从上/下走过来 // (2)a,b一个上一个下走过来 // 共4种 //d... ...
分类:
编程语言 时间:
2020-06-06 21:42:53
阅读次数:
68
#include<bits/stdc++.h> using namespace std; //状态压缩dp,二进制法,搜索法的优化 int dp[1<<20][21],n;//最多20个点,就是20位二进制 //在状态是i,末位点是j的情况下的最小值(因为状态没有顺序信息,但是其实只需要知道末尾点即... ...
分类:
其他好文 时间:
2020-06-06 21:35:25
阅读次数:
73
#include using namespace std; //和方格取数一样,一来一回可以看成走两次 int a[51][51],m,n,dp[51][51][51][51]={0}; int main() { cin>>m>>n; for(int i=1;i>a[i][j]; for( int ... ...
分类:
其他好文 时间:
2020-06-06 21:32:36
阅读次数:
85
#include using namespace std; const int maxn=100+10; //开新木板不一定要刚好一样大,可以比i大 //不开的情况不考虑,因为开了的情况因为开的大小由最大值确定,所以包含了不开的情况 //他给的测试数据有迷惑性 //这个题根据经验想到了要枚举,在根据... ...
分类:
其他好文 时间:
2020-06-06 21:30:26
阅读次数:
62
#include using namespace std; //加分二叉树 int n,dp[40][40]={0},a[40],ans=0,root[40][40]; void f(int i,int j){ if(i>j) return; cout>n; for(int i=1;i>a[i]; ... ...
分类:
其他好文 时间:
2020-06-06 21:27:21
阅读次数:
60
#include <bits/stdc++.h> using namespace std; #define MAX 100 class UnionSet{ private: int data[MAX+1];//即上级数组 public: UnionSet(int len){ for(int i=1;... ...
分类:
其他好文 时间:
2020-06-06 21:25:48
阅读次数:
62
#include using namespace std; //算法提高,能量项链,就是可以转圈的矩阵连乘问题 //把1->n扩展为1->n->n+1->2*n,然后对其进行dp,这样就循环起来了 int dp[2000][2000],n,a[1000],ans=0;//用i表示左维度,i+1表示右... ...
分类:
其他好文 时间:
2020-06-06 21:24:30
阅读次数:
48
#include<bits/stdc++.h> using namespace std; #define index(i) i-1 const int N=110; string a,b; //i代表a串右位置、j代表b串右位置 //比较ai bj 如果=。。。 //如果!=,那么1.假设i存在于最... ...
分类:
其他好文 时间:
2020-06-06 21:24:15
阅读次数:
45
#include <bits/stdc++.h> using namespace std; int dp[100][40000]={0},n,m,w[100],v[100],G[100][100]={0}; //算法提高,类似于机器人问题 //树形dp,用边来表示花费,设u->v那么w[v]为这条边... ...
分类:
其他好文 时间:
2020-06-06 21:22:49
阅读次数:
53