Light oj 1018 - Brush (IV) 状态压缩】的更多相关文章

题目大意: 给出n个点的坐标,求至少画多少掉直线才能连接所有点. 题目思路:状态压缩 首先经行预处理,求出所有状态下,那些点不在该状态内 以任意两点为端点求出这条直线的状态 枚举所有状态,找出不在当前状态下的两点,以这两点所形成的直线经行更新dp. 其中dp[i]表示在i状态下的最优解. #include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<vect…
题目大意:     一个二维平面上有N个点,一把刷子,刷一次可以把一条线上的所有点都刷掉.问最少刷多少次,可以把全部的点都刷完 状态压缩DP, 用记忆化搜索来写, 需要有个优化不然会超时. ========================================================================================   #include<cstdio> #include<cstring> #include<iostream&g…
题目链接 大概题意是有n个男的n个女的(原谅我这么说,我是粗人),给你一个n*n的矩阵,第i行第j列表示第i个女(男)对第j个男(女)的好感度,然后要安排n对相亲,保证都是正常的(无搞基百合之类的),然后求怎么安排能使好感度和最大,求出最大值. 开始试了纯暴力的方法,时间复杂度是n!果断超时 #include <iostream> #include <string.h> #include <algorithm> using namespace std; int vis[…
题目大意: 给你一个base 进制的数字,把这个数字的每一位进行全排列,问有多少个数字是可以整除k的. 题目解析: #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<cmath> #include<queue> #include<vector> #include<map> using namesp…
1018 - Brush (IV)    PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Mubashwir returned home from the contest and got angry after seeing his room dusty. Who likes to see a dusty room after a brain storming programming conte…
1018 - Brush (IV)    PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Mubashwir returned home from the contest and got angry after seeing his room dusty. Who likes to see a dusty room after a brain storming programming conte…
http://www.lightoj.com/volume_showproblem.php?problem=1018   Mubashwir returned home from the contest and got angry after seeing his room dusty. Who likes to see a dusty room after a brain storming programming contest? After checking a bit he found a…
题目链接:http://lightoj.com/volume_showproblem.php? problem=1018 题意分析:平面上有不超过N个点,如今能够随意方向划直线将它们划去,问:最少要划几次能够把全部的点划去? 解题思路:我们能够使用集合S表示:有哪些点还没有被划掉,然后转移 dp[s] = min(dp[s &(~line[i][j])]) + 1;这里涉及到line[i][j]的处理,它代表的是在i点和j点构成的直线上一共同拥有几个点,须要预先处理. 边界条件就是S中集合元素…
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1019 题目大意:Tanvir想从节点1的位置走到节点n的位置, 输出最短距离, 如果不存在输出"Impossible". 解题思路:dijkstra模版题 代码如下: #include<bits/stdc++.h> using namespace std; typedef long long LL; const int INF = 0x3f3f3f3f;…
题目大意:     在一个二维平面上有N个点,散落在这个平面上.现在要清理这些点.有一个刷子刷子的宽度是w. 刷子上连着一根绳子,刷子可以水平的移动(在X轴方向上).他可以把刷子放在任何一个地方然后开始移动(只能是水平的). 他可以把在宽度为w的这个水平方向上的所有点都擦除掉.问最多移动k次,最多可以擦除多少个点? 题目解析:     根据题意,其实我们只需要考虑y坐标就OK了. 然后排序,把数据处理一下.     dp[i][k] = dp[第i个位置][移动的是第k次] = 最大数量   …