Light OJ 1018 - Brush (IV)
题目大意:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;
#define Max(a,b) (a>b?a:b)
const int INF = 1e9+;
const int maxn = ;
const int MOD = ;
int Line[maxn][maxn];
int dp[], n;
struct node
{
int x, y;
} P[maxn]; int DFS(int sta)
{
if(dp[sta] != - )
return dp[sta];
dp[sta] = INF;
int cnt = ;
for(int i=; i<n; i++)
if( (sta&(<<i)) ) cnt ++; if(cnt == )
return dp[sta] = ;
else if(cnt <= )
return dp[sta] = ; for(int a=; a<n; a++)
{
if( (sta&(<<a)) )
{
for(int b=a+; b<n; b++)
{
if((sta&(<<a)) == ) continue;
int newSta = (sta|Line[a][b]) - Line[a][b];
dp[sta] = min(dp[sta], DFS(newSta) + );
}
break;///此处是优化
}
}
return dp[sta];
} int main()
{
int T, Lim, cas = ;
scanf("%d", &T);
while(T --)
{
memset(dp, -, sizeof(dp));
memset(Line, , sizeof(Line));
scanf("%d",&n);
for(int i=; i<n; i++)
scanf("%d %d", &P[i].x, &P[i].y); for(int i=; i<n; i++)
{
Line[i][i] = (<<i);
for(int j=i+; j<n; j++)
{
for(int k=; k<n; k++)
{
if( (P[i].y-P[j].y)*(P[i].x-P[k].x) == (P[i].y-P[k].y)*(P[i].x-P[j].x) )
Line[i][j] += (<<k);
}
Line[j][i] = Line[i][j];
} }
dp[] = ;
Lim = (<<n)-;
printf("Case %d: %d\n",cas ++ , DFS(Lim));
}
return ;
}
Light OJ 1018 - Brush (IV)的更多相关文章
- Light oj 1018 - Brush (IV) 状态压缩
题目大意: 给出n个点的坐标,求至少画多少掉直线才能连接所有点. 题目思路:状态压缩 首先经行预处理,求出所有状态下,那些点不在该状态内 以任意两点为端点求出这条直线的状态 枚举所有状态,找出不在当前 ...
- Lightoj 1018 - Brush (IV)
1018 - Brush (IV) PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Muba ...
- 1018 - Brush (IV)
1018 - Brush (IV) PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Muba ...
- (状压) Brush (IV) (Light OJ 1018)
http://www.lightoj.com/volume_showproblem.php?problem=1018 Mubashwir returned home from the contes ...
- [LightOJ 1018]Brush (IV)[状压DP]
题目链接:http://lightoj.com/volume_showproblem.php? problem=1018 题意分析:平面上有不超过N个点,如今能够随意方向划直线将它们划去,问:最少要划 ...
- Light OJ 1019 - Brush (V)(图论-dijkstra)
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1019 题目大意:Tanvir想从节点1的位置走到节点n的位置, 输出最短距离, ...
- Light OJ 1017 - Brush (III)
题目大意: 在一个二维平面上有N个点,散落在这个平面上.现在要清理这些点.有一个刷子刷子的宽度是w. 刷子上连着一根绳子,刷子可以水平的移动(在X轴方向上).他可以把刷子放在任何一个地方然后开 ...
- Light OJ 1114 Easily Readable 字典树
题目来源:Light OJ 1114 Easily Readable 题意:求一个句子有多少种组成方案 仅仅要满足每一个单词的首尾字符一样 中间顺序能够变化 思路:每一个单词除了首尾 中间的字符排序 ...
- Light OJ 1429 Assassin`s Creed (II) BFS+缩点+最小路径覆盖
题目来源:Light OJ 1429 Assassin`s Creed (II) 题意:最少几个人走全然图 能够反复走 有向图 思路:假设是DAG图而且每一个点不能反复走 那么就是裸的最小路径覆盖 如 ...
随机推荐
- 最近的两个小项目,1:在Vscode里写C/C++
时间过得真快,一眨眼一个多月没更新了,但这一个月我可没偷懒啊,真的是忙.粘上两篇ReadMe勉强凑合一下,保持博客更新是好习惯. VscodeCppDemo Try to develop C/C++ ...
- 45种Javascript技巧大全
JavaScript是一个绝冠全球的编程语言,可用于Web开发.移动应用开发(PhoneGap.Appcelerator).服务器端开发(Node.js和Wakanda)等等.JavaScript还是 ...
- const和volatile的区别
一.关键字const有什么含意? 只要一听到说:“const意味着常数”,就知道我正在和一个业余者打交道.去年Dan Saks已经在他的文章里完全概括了const的所有用法,因此ESP(译者:Embe ...
- ios strong weak 的区别 与 理解
先一句话总结:strong类保持他们拥有对象的活着,weak类他们拥有的对象被人家一牵就牵走,被人家一干就干死.(strong是一个好大哥所以strong,呵呵,weak是一个虚大哥所以weak,呵呵 ...
- 打开自定义链接新窗口(safari JS prompt的坑!)2016.03.08
很简单的一个小练习,但做的过程中发现safari的一个坑,使用prompt()方法的时候,点击取消和不输入一样,会返回空字符' ',而不是null! 要求: 制作新按钮,"新窗口打开网站&q ...
- 初涉JavaScript模式 (1) : 简介
什么是模式? 广义上的模式是指 :在物体或事件上,产生的一种规律变化与自我重复的样式与过程.在模式之中,某些固定的元素不断以可预测的方式周期性重现.最基本而常见的模式,称为密铺,具备重复性以及周期性两 ...
- js 支持的原始数据类型
原始数据类型: 数值型: 1.十进制数 <script> var a =12; a = -12 a = 12.4 a =.23e2 //=>23 a = 2e3 //=>200 ...
- Dynamic Web Module 3.0 requires Java 1.6 or newer报错
在项目的pom.xml的<build></build>标签中加入: <plugins> <plugin> <groupId>org.apac ...
- python模块之socket
43.python模块之socket: Python在网络通讯方面功能强大,学习一下Socket通讯的基本方式 UDP通讯: Server: import socket port=8081 ...
- wndows常用命令
1. 远程桌面 mstsc (Microsoft terminal services client)