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. linux 配置文件要不要加上#! /bin/bash

    现在一般的linux系统默认的shell都是bash.所以但很多unix系统可能会用bourne shell.csh或者ksh等来作为用户默认shell 如果你在写shell脚本的时候,用的语法只有b ...

  2. [NOI2001] 炮兵阵地 (状压Dp经典例题)

    如果您的电脑比较优秀能在 1sec 内跑过 2^1000 的时间复杂度,不妨你可以尝试一下,其实实际时间复杂度远远少于 2^1000,作为骗分不错的选择QAQ,然后我们来分析一下正解: 很显然此题是一 ...

  3. 儿子写日记 : " 夜深了,妈妈在打麻将,爸爸在上网……"

    儿子写日记 : " 夜深了,妈妈在打麻将,爸爸在上网……"              爸爸检查时,很不满意地说 : " 日记源于生活,但要高于生活 !"    ...

  4. zoj 2109 FatMouse' Trade

    FatMouse' Trade Time Limit: 2 Seconds      Memory Limit: 65536 KB FatMouse prepared M pounds of cat ...

  5. C# easyui json类

    using System; using System.Data; using System.Text; namespace Common { public class JsonHelp { priva ...

  6. poj 1579 简单dp由下往上

    #include<stdio.h> #include<string.h> #define N 22 int dp[N][N][N]; int main() { int n,m, ...

  7. 那些“不务正业”的IT培训公司

    Before First 大四下期了,现在准备找一份Java开发的实习工作,于是在各大网站上投递简历-智联招聘.51job.拉勾网,慧眼识真金的我必然会把培训机构给过滤掉,对于重庆来说招聘实习的公司少 ...

  8. poj2773求第K个与m互质的数

    //半年前做的,如今回顾一下,还是有所收货的,数的唯一分解,.简单题. #include<iostream> #include<cstring> using namespace ...

  9. P1396 营救 洛谷

    https://www.luogu.org/problem/show?pid=1396 题目描述 “咚咚咚……”“查水表!”原来是查水表来了,现在哪里找这么热心上门的查表员啊!小明感动的热泪盈眶,开起 ...

  10. Git入门使用

    Git入门使用 安装Git 软件包如: Git-2.7.2-32-bit_setup.1457942412.exe TortoiseGit-1.8.12.0-64bit.msi 安装时候,直接点下一步 ...