1018 - Brush (IV)
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 contest? After checking a bit he found an old toothbrush in his room. Since the dusts are scattered everywhere, he is a bit confused what to do. So, he called Shakib. Shkib said that, 'Use the brush recursively and clean all the dust, I am cleaning my dust in this way!'

So, Mubashwir got a bit confused, because it's just a tooth brush. So, he will move the brush in a straight line and remove all the dust. Assume that the tooth brush only removes the dusts which lie on the line. But since he has a tooth brush so, he can move the brush in any direction. So, he counts a move as driving the tooth brush in a straight line and removing the dusts in the line.

Now he wants to find the maximum number of moves to remove all dusts. You can assume that dusts are defined as 2D points, and if the brush touches a point, it's cleaned. Since he already had a contest, his head is messy. That's why he wants your help.

Input

Input starts with an integer T (≤ 1000), denoting the number of test cases.

Each case starts with a blank line. The next line contains three integers N (1 ≤ N ≤ 16)N means that there are N dust points. Each of the next N lines will contain two integers xi yi denoting the coordinate of a dust unit. You can assume that (-1000 ≤ xi, yi ≤ 1000) and all points are distinct.

Output

For each case print the case number and the minimum number of moves.

Sample Input

Output for Sample Input

2

3

0 0

1 1

2 2

3

0 0

1 1

2 3

Case 1: 1

Case 2: 2

/* ***********************************************
Author :guanjun
Created Time :2016/6/22 20:44:30
File Name :1018.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 0x3f3f3f3f
#define maxn 1000010
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << ;
const double eps=1e-;
using namespace std; int dp[maxn],n,l[][];
struct node{
int x,y;
}nod[];
bool Gx(node a,node b,node c){
//int tmp=(a.x*b.y-a.y*b.x)+(b.x*c.y-b.y*c.x)+(c.x*a.y-c.y*a.x);
//if(tmp==0)return true;
if((a.x-b.x)*(c.y-b.y)-(a.y-b.y)*(c.x-b.x)==)return true;
return false;
}
int dfs(int s){
if(dp[s]!=INF)return dp[s];
int cnt=;
for(int i=;i<n;i++)if(s&(<<i))cnt++;
if(cnt==)return ;
if(cnt<=)return ;
for(int i=;i<n;i++){
if(s&(<<i)){
for(int j=i+;j<n;j++){
if(s&(<<j))
dp[s]=min(dp[s],dfs(s-(s&l[i][j]))+);
}
break;
}
}
return dp[s];
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int T;
cin>>T;
for(int t=;t<=T;t++){
cin>>n;
for(int i=;i<n;i++)scanf("%d %d",&nod[i].x,&nod[i].y);
for(int i=;i<n;i++)l[i][i]=;
for(int i=;i<n;i++){
for(int j=i+;j<n;j++){
l[i][j]=(<<i)|(<<j);
for(int k=;k<n;k++){
if(Gx(nod[i],nod[j],nod[k]))
l[i][j]|=(<<k);
l[j][i]=l[i][j];
}
}
}
int top=<<n;
memset(dp,INF,sizeof dp);
dp[]=;
printf("Case %d: %d\n",t,dfs(top-));
}
return ;
}

Lightoj 1018 - Brush (IV)的更多相关文章

  1. [LightOJ 1018]Brush (IV)[状压DP]

    题目链接:http://lightoj.com/volume_showproblem.php? problem=1018 题意分析:平面上有不超过N个点,如今能够随意方向划直线将它们划去,问:最少要划 ...

  2. 1018 - Brush (IV)

    1018 - Brush (IV)    PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Muba ...

  3. Light OJ 1018 - Brush (IV)

    题目大意:     一个二维平面上有N个点,一把刷子,刷一次可以把一条线上的所有点都刷掉.问最少刷多少次,可以把全部的点都刷完 状态压缩DP, 用记忆化搜索来写, 需要有个优化不然会超时. ===== ...

  4. Light oj 1018 - Brush (IV) 状态压缩

    题目大意: 给出n个点的坐标,求至少画多少掉直线才能连接所有点. 题目思路:状态压缩 首先经行预处理,求出所有状态下,那些点不在该状态内 以任意两点为端点求出这条直线的状态 枚举所有状态,找出不在当前 ...

  5. Brush (IV) LightOJ - 1018

    题意:平面上有一些点,每刷一次可以把同一条直线上的点都刷光,问最少几次把所有点刷光. 方法: 显然是一个状态压缩dp.ans[S]表示把S集合中点刷掉的最少次数.最开始想到的方法是如果S中只有一个或两 ...

  6. (状压) Brush (IV) (Light OJ 1018)

    http://www.lightoj.com/volume_showproblem.php?problem=1018   Mubashwir returned home from the contes ...

  7. lightoj 1018 dp

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1018 #include <cstdio> #include <cst ...

  8. lightOJ 1017 Brush (III) DP

    题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1017 搞了一个下午才弄出来,,,,, 还是线性DP做的不够啊 看过数据量就知道 ...

  9. LightOJ 1017 - Brush (III) 记忆化搜索+细节

    http://www.lightoj.com/volume_showproblem.php?problem=1017 题意:给出刷子的宽和最多横扫次数,问被扫除最多的点是多少个. 思路:状态设计DP[ ...

随机推荐

  1. SpringMVC最核心

    如图所示:

  2. Java高级程序员面试题

    1.你认为项目中最重要的过程是那些? 分析.设计阶段  尽量找出进度的优先级 2.如果给你一个4-6人的team,怎么分配? 挑选一技术过硬的人作为我的替补.其它人平均分配任务,每周进行全面的任务分配 ...

  3. spring boot学习02【如何在spring boot项目中访问jsp】

    1.配置application.properties文件 打开application.properties追加 spring.mvc.view.prefix=/WEB-ROOT/ spring.mvc ...

  4. Android滚动页面位置指示器:CircleIndicator

     Android滚动页面位置指示器:CircleIndicator CircleIndicator是github上的一个开源的用于页面滚动时候的位置指示器,指示当前页面在总的页面中的位置和前后位置 ...

  5. hexo干货系列:(四)将hexo博客同时托管到github和coding

    前言 之前我们把hexo托管在github,但是毕竟github是国外的,访问速度上还是有点慢,所以想也部署一套在国内的托管平台,之前查资料听说gitcafe,但是听说gitcafe已经被coding ...

  6. 如何解决安装istio后istioctl命令每次使用都需要重新配置路径

    Kubernetes在安装istio后初次使用istioctl命令时会提示istioctl command not found 这时候如果在istio文件夹的根目录下配置 export PATH=$P ...

  7. 从零到一,使用实时音视频 SDK 一起开发一款 Zoom 吧

    zoom(zoom.us) 是一款受到广泛使用的在线会议软件.相信各位一定在办公.会议.聊天等各种场景下体验或者使用过,作为一款成熟的商业软件,zoom 提供了稳定的实时音视频通话质量,以及白板.聊天 ...

  8. 安卓巴士Android开发神贴整理

    10个经典的Android开源应用项目 http://www.apkbus.com/android-13519-1-1.html 安卓巴士总结了近百个Android优秀开源项目,覆盖Android开发 ...

  9. app后端搜索入门

    现在人们的网络生活已经离不开搜索了,遇到不懂的问题,想知道的事情,搜索一下,就知道答案. 在app中,最常见的搜索情景就是搜索用户.只有几百,几千的用户量时,可以直接用用like这样的模糊查询,但是, ...

  10. iterm2退出时保存会话状态,下次打开恢复

    可以保存已经打开的窗口,本机进入的目录 无法保存ssh连接状态,无法保存ipython状态等 设置方法: 1.这里设置为yes,据说,反复修改一次,重启才起作用,实在有问题就试试 2.这里设置一下 3 ...