随笔分类 -  动态规划

摘要:最后补充一下滚动数组降维: 其实就是状态转移后前面的数组的空间不用了 ,会造成浪费,而滚动数组就是利用这部分空间 写Dp经常需要大家开高维数组,比如F[t][i][j]。有的时候转移仅需要上一维数组,如F[t 1][i][j],而F[t 2],F[t 3]都不再有用,留着占用大量空间。我们可以用滚动 阅读全文
posted @ 2018-08-26 13:42 Roni_i 阅读(380) 评论(0) 推荐(0) 编辑
摘要:A 求和 时间限制: 1 Sec 空间限制: 256 MB 输入输出文件名:A.in,A.out 题目描述 给出一棵以1为根的有n个节点的树,树上每条边都有其边权。 求所有点对之间的路径上的边权和的总和。 输入格式: 第一行为n 接下来n 1行,每行三个整数,分别表示一条边的两端点编号和边权。(编号 阅读全文
posted @ 2018-08-25 22:14 Roni_i 阅读(538) 评论(0) 推荐(0) 编辑
摘要:Edward has an array A with N integers. He defines the beauty of an array as the summation of all distinct integers in the array. Now Edward wants to k 阅读全文
posted @ 2018-08-22 16:51 Roni_i 阅读(151) 评论(0) 推荐(0) 编辑
摘要:有一个只含0和1的长度为n的串,问不含有101的所有串的个数。 ——不存在连续的101、010、111的字符串数量 HDU:https://cn.vjudge.net/problem/HDU-3485 51nod: https://blog.csdn.net/Viscu/article/detail 阅读全文
posted @ 2018-08-16 18:36 Roni_i 阅读(220) 评论(0) 推荐(0) 编辑
摘要:Since 1945, when the first nuclear bomb was exploded by the Manhattan Project team in the US, the number of nuclear weapons have soared across the glo 阅读全文
posted @ 2018-08-08 09:45 Roni_i 阅读(146) 评论(0) 推荐(0) 编辑
摘要:[树形DP](https://cn.vjudge.net/contest/123963#overview) #include<cstdio> #include<string> #include<cstdlib> #include<cmath> #include<iostream> #include< 阅读全文
posted @ 2018-08-06 00:54 Roni_i 阅读(282) 评论(0) 推荐(0) 编辑
摘要:You, the leader of Starship Troopers, are sent to destroy a base of the bugs. The base is built underground. It is actually a huge cavern, which consi 阅读全文
posted @ 2018-08-06 00:20 Roni_i 阅读(291) 评论(0) 推荐(0) 编辑
摘要:ACboy很喜欢玩一种战略游戏,在一个地图上,有N座城堡,每座城堡都有一定的宝物,在每次游戏中ACboy允许攻克M个城堡并获得里面的宝物。但由于地理位置原因,有些城堡不能直接攻克,要攻克这些城堡必须先攻克其他某一个特定的城堡。你能帮ACboy算出要获得尽量多的宝物应该攻克哪M个城堡吗? Input每 阅读全文
posted @ 2018-08-05 21:59 Roni_i 阅读(391) 评论(0) 推荐(0) 编辑
摘要:不要62 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 56193 Accepted Submission(s): 21755 Problem 阅读全文
posted @ 2018-08-05 15:53 Roni_i 阅读(289) 评论(0) 推荐(0) 编辑
摘要:1026: [SCOI2009]windy数 Description windy定义了一种windy数。不含前导零且相邻两个数字之差至少为2的正整数被称为windy数。 windy想知道,在A和B之间,包括A和B,总共有多少个windy数? windy定义了一种windy数。不含前导零且相邻两个数字 阅读全文
posted @ 2018-08-05 15:38 Roni_i 阅读(219) 评论(0) 推荐(0) 编辑
摘要:#include #include #include #include using namespace std; int t; long long dp[19][19][2005]; long long l, r; int digit[20]; long long dfs(int len,...int if4..., bool limit) { if (len == 0) ... 阅读全文
posted @ 2018-08-05 14:46 Roni_i 阅读(221) 评论(0) 推荐(0) 编辑
摘要:1:给出一个括号字符串,问这个字符串中符合规则的最长子串的长度。 【逆序枚举区间长度】 #include<cstdio> #include<string> #include<cstdlib> #include<cmath> #include<iostream> #include<cstring> # 阅读全文
posted @ 2018-08-03 21:50 Roni_i 阅读(960) 评论(0) 推荐(1) 编辑
摘要:题目描述 某大学有N个职员,编号为1~N。他们之间有从属关系,也就是说他们的关系就像一棵以校长为根的树,父结点就是子结点的直接上司。现在有个周年庆宴会,宴会每邀请来一个职员都会增加一定的快乐指数Ri,但是呢,如果某个职员的上司来参加舞会了,那么这个职员就无论如何也不肯来参加舞会了。所以,请你编程计算 阅读全文
posted @ 2018-08-02 20:45 Roni_i 阅读(162) 评论(0) 推荐(0) 编辑
摘要:0103 最短Hamilton路径 0x00「基本算法」例题 描述 给定一张 n(n≤20) 个点的带权无向图,点从 0~n 1 标号,求起点 0 到终点 n 1 的最短Hamilton路径。 Hamilton路径的定义是从 0 到 n 1 不重不漏地经过每个点恰好一次。 输入格式 第一行一个整数n 阅读全文
posted @ 2018-07-02 00:59 Roni_i 阅读(427) 评论(0) 推荐(1) 编辑
摘要:``` include using namespace std; const int MAXN=200005; int dp[MAXN],a[MAXN],n,ans= 100000; int main(){ scanf("%d",&n); for(int i=1;i 阅读全文
posted @ 2018-06-25 06:53 Roni_i 阅读(118) 评论(0) 推荐(0) 编辑
摘要:【链接】: "CF987C" 【分析】:先求出每个s【i】后面比s【i】大的c【i】的最小值,然后枚举前两个数c(i),c(j)以及 j 后面 递增且存在最小值 的dp(j) 【代码】: include using namespace std; const int INF = 0x3f3f3f3f; 阅读全文
posted @ 2018-06-01 19:03 Roni_i 阅读(287) 评论(0) 推荐(0) 编辑
摘要:I NEED A OFFER! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 33247 Accepted Submission(s): 13 阅读全文
posted @ 2018-05-19 22:12 Roni_i 阅读(285) 评论(0) 推荐(0) 编辑
摘要:Robberies Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 29499 Accepted Submission(s): 10797 Pr 阅读全文
posted @ 2018-05-19 21:41 Roni_i 阅读(227) 评论(0) 推荐(0) 编辑
摘要:Robberies Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 29495 Accepted Submission(s): 10795 Pr 阅读全文
posted @ 2018-05-18 19:00 Roni_i 阅读(204) 评论(0) 推荐(0) 编辑
摘要:Input 输入数据首先包含一个正整数C,表示有C组测试用例,每组测试用例的第一行是两个整数n和m(1 include include include include include include include include include include include include in 阅读全文
posted @ 2018-05-18 13:34 Roni_i 阅读(148) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示