# LightOJ 1018 - Brush (IV)

题意就是给一些点，问最少要连几条线，可以将这些点全部覆盖。

//
//  Created by  CQU_CST_WuErli
//
// #include<bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#define CLR(x) memset(x,0,sizeof(x))
#define OFF(x) memset(x,-1,sizeof(x))
#define MEM(x,a) memset((x),(a),sizeof(x))
#define ALL(x) x.begin(),x.end()
#define AT(i,v) for (auto &i:v)
#define For_UVa if (kase!=1) cout << endl
#define BUG cout << "I am here" << endl
#define lookln(x) cout << #x << "=" << x << endl
#define look(x) cout << #x << "=" << x
#define SI(a) scanf("%d",&a)
#define SII(a,b) scanf("%d%d",&a,&b)
#define SIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define Lson l,mid,rt<<1
#define Rson mid+1,r,rt<<1|1
#define Root 1,n,1
#define BigInteger bign
const int MAX_L=2005;// For BigInteger
const int INF_INT=0x3f3f3f3f;
const long long INF_LL=0x7fffffff;
const int MOD=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
typedef long long  ll;
using namespace std;

struct P{
int x,y;
};
P p[20];
int n;
int dp[1<<20];
int line[20][20];

bool Online(P& a,P& b,P& c) {
return (b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x)==0;
}

int dfs(int st) {
if (dp[st]!=-1) return dp[st];
dp[st]=INF_INT;
int cnt=0;
for (int i=1;i<=n;i++) if (st&(1<<i)) cnt++;
if (cnt==0) return dp[st]=0;
if (cnt<=2) return dp[st]=1;
for (int i=1;i<=n;i++) {
if (st&(1<<i)) {
for (int j=i+1;j<=n;j++) {
if (st&(1<<j)) {
dp[st]=min(dp[st],dfs(st-(st&line[i][j]))+1);
}// st-(st&line[i][j])是吧这个集合中一些元素减掉
}
break;  // 这里不跳出就会T
}
}
return dp[st];
}

int main(){
#ifdef LOCAL
freopen("C:\\Users\\john\\Desktop\\in.txt","r",stdin);
//  freopen("C:\\Users\\john\\Desktop\\out.txt","w",stdout);
#endif
int T_T;
for (int kase=scanf("%d",&T_T);kase<=T_T;kase++) {
cin >> n;
for (int i=1;i<=n;i++) cin >> p[i].x >> p[i].y;
OFF(dp);CLR(line);
for (int i=1;i<=n;i++) {
for (int j=i+1;j<=n;j++) {
for (int k=1;k<=n;k++) {
if (Online(p[i],p[j],p[k])) line[i][j]|=(1<<k);
}
}
}
int ans=dfs((1<<(n+1))-1);
cout << "Case " << kase << ": " << ans << endl;
}
return 0;
}

01-17 504

08-11 1305

11-04 217

08-14 591

11-09 331

04-13 304

10-29 253

10-27 264

01-17 365

09-09 221